Opened 9 years ago

Closed 7 years ago

Last modified 7 years ago

#3406 closed defect (fixed)

[PATCH] Units attack farms instead of capturing/ignoring them

Reported by: Stan Owned by: otero
Priority: Should Have Milestone: Alpha 20
Component: UI & Simulation Keywords: patch
Cc: mimo, otero_xd@… Patch:

Description (last modified by elexis)

I played with three Petra AIs in Very Hard difficulty on Thessalonians plains, and instead of capturing farms, they started destroying them.

http://trac.wildfiregames.com/raw-attachment/ticket/3406/field_haters.gif

I think behaviour should be

  • Neutral Farm → Capture
  • Enemy Farm if enemy around, ignore, else capture.

Attachments (6)

commands.txt (180.1 KB ) - added by Stan 9 years ago.
Related commands
t3406_prevent_attacking_field_WIP_v1.patch (901 bytes ) - added by elexis 8 years ago.
Doesn't work for mirages and we should implement an attackable attribute for structures.
field_haters.gif (1.1 MB ) - added by elexis 8 years ago.
After capturing a CC, the first thing the units do is attacking the fields, no matter if they are attacked by 6 towers and a fortress (aggressive stance, which is the default).
commands.2.txt (25.0 KB ) - added by elexis 8 years ago.
Simple testcase as seen in the gif.
decay_field_v1.patch (42.4 KB ) - added by otero 8 years ago.
decay_field_v2.patch (42.8 KB ) - added by otero 8 years ago.

Download all attachments as: .zip

Change History (33)

by Stan, 9 years ago

Attachment: commands.txt added

Related commands

comment:1 by mimo, 9 years ago

Do you mean farmstead ? or fields ? I guess fields as the AI do capture farmsteads. But then, this proposition is invalid as fields are not capturables presently. That feature can be changed, but that's more a design choice rather than an AI defect.

comment:2 by Stan, 9 years ago

I meant fields. Oh I thought you could, It made sense to me. Anyway, for the time being i don't think they should attack fields.

comment:3 by mimo, 9 years ago

Component: AIUI & Simulation

Well, it depends if you are raiding and want to destroy the enemy economy. Otherwise, most of the time, the units attacking a field are idle units nearby an enemy field which are automatically made attacking the field by UnitAI.

But I also did not liked this behaviour and had some thought about it, but never came to something really finalized:

  • a simple solution would be to change the owner of the fields when constructed and make them gaia. UnitAI would then no more attack them automatically, and that would reflect more the fact that all players can gather on it.
  • another possibility would be to change radically the way fields are used. We could make them non-attackable, but any fields without gatherers would health-decay while fields with gatherers would slowly regain health (that would represent the fact that fields not worked on become uncultivated land). So when raiding, killing or making flee the gatherers would make the field decay. And to make these raids more useful, the gathering rate would be scaled by the health ratio of the field, so that after a raid the field will take some time to be fully efficient again.

comment:4 by Stan, 9 years ago

I like 2)

AI attacks gaia fields too though.

comment:5 by elexis, 9 years ago

One more vote for 2).

It would make the game more interesting, as unused fields are penalized, more efficient build orders promoted and raids becoming more viable.

comment:6 by Lionkanzen, 9 years ago

Vote for 2

comment:7 by mimo, 9 years ago

In 17015:

petra: be more restrictive to attack a field, refs #3406

comment:8 by Stan, 8 years ago

Keywords: design added

by elexis, 8 years ago

Doesn't work for mirages and we should implement an attackable attribute for structures.

by elexis, 8 years ago

Attachment: field_haters.gif added

After capturing a CC, the first thing the units do is attacking the fields, no matter if they are attacked by 6 towers and a fortress (aggressive stance, which is the default).

comment:9 by elexis, 8 years ago

Description: modified (diff)

by elexis, 8 years ago

Attachment: commands.2.txt added

Simple testcase as seen in the gif.

comment:10 by ffm, 8 years ago

Vote for 2. Even if you plan to destroy the enemy economy, the fields have the lowest priority. Better attack farmstead, storehouse, traders and women. Attacking fields waists too much time in a very stressy situation. Every other task after capturing/destroying the cc is more appropriate (attacking units, capture towers or other structures).

comment:11 by wraitii, 8 years ago

Milestone: BacklogAlpha 20

comment:12 by elexis, 8 years ago

Milestone: Alpha 20Backlog

Backlogging due to lack of progress.

comment:13 by elexis, 8 years ago

With #3741, the originally reported problem issue with fields is addressed. Should we make a clean ticket for the automatically-decaying fields and gatherrate-adaption?

comment:14 by otero, 8 years ago

Keywords: patch review added
Owner: set to otero
Summary: Units attack farms instead of capturing/ignoring them[PATCH]Units attack farms instead of capturing/ignoring them

I solved the problem of farm fields with decaying health when the field doesn't have gatherers. I submit my first attempt which takes a few considerations:

  1. Buildings can be divided in two Militar and Civil. Militar means that the building has the possibility to attack an enemy while a Civil can't.
  1. The decaying of the field starts 15 seconds after the number of gatherers reaches zero, and the process is stopped one the gatherers return. Also it take 15 seconds for a field to decay completely, the rate of decaying is given by a tag inside the Health tag of the field as is the amount of points.

I don't know if it's the most efficient way to solve the problem, but I found it works and doesn't make worse the performance of the game. Any way if there is a problem let me know, I wanted to create a new thread but I thought I'll just add it here.

The patch includes some minor changes also, like transformation of var into let and some white spaces eliminated.

by otero, 8 years ago

Attachment: decay_field_v1.patch added

comment:15 by otero, 8 years ago

Milestone: BacklogAlpha 21

comment:16 by otero, 8 years ago

Cc: otero_xd@… added

comment:17 by Imarok, 8 years ago

shouldn't it be "Military"? (I think the word "Militar" does not exist)

comment:18 by fatherbushido, 8 years ago

I thought that was fixed in r17654

comment:19 by Imarok, 8 years ago

With r17654 the fields belong to whom the terrain owns. So hostile units still will attack fields before attacking towers or fortresses.

comment:20 by otero, 8 years ago

Fixed the mistake of Militar to Military, and fixed a little problem when the state machine of some entities is faster creating race conditions.

by otero, 8 years ago

Attachment: decay_field_v2.patch added

comment:21 by sanderd17, 8 years ago

BuildingAI specifically deals with buildings shooting arrows, so that component shouldn't be (ab)used for other purposes.

Instead (when following your proposal of improving UnitAI target selection), it would be better to let the UnitAI just test if there's a BuildingAI on the target, and how many arrows it shoots.

And that decay isn't needed I think, since fields now already autoconvert to the territory owner. So making UnitAI more clever would be enough.

comment:22 by sanderd17, 8 years ago

Keywords: review removed

comment:23 by Imarok, 8 years ago

But wouldn't the decay be a nice feature to make raids more effective?

comment:24 by elexis, 8 years ago

Milestone: Alpha 21Alpha 22

Feature freeze in 2 days.

comment:25 by elexis, 7 years ago

Keywords: design removed
Milestone: Alpha 22Alpha 20
Priority: Must HaveShould Have
Resolution: fixed
Status: newclosed
Summary: [PATCH]Units attack farms instead of capturing/ignoring them[PATCH] Units attack farms instead of capturing/ignoring them

Calling this ticket fixed by r17654 and #4194. Fields will switch to the new territory owner immediately. Attacking units will first kill other units running around before doing anything to buildings or fields.

oteros patch implements decay for fields which are not gathered from. The implementation is not too nice as it comes with hardcoding of the field type in UnitAI, while the template should specify things. I'm not against the idea of decay of gathered resources, for example animals could also decay if they are not gathered from (or decay regardless). If so, this should be done in a new ticket and we should find at least 2 team members who endorse the design (candidates: mimo, fatherbushido, scythetwirler, Yves).

comment:26 by Palaxin, 7 years ago

#4194 was fixed in Alpha 21, why then allocate this ticket to Alpha 20?

comment:27 by elexis, 7 years ago

r17654 was done in Alpha 20

Note: See TracTickets for help on using tickets.