Page MenuHomeWildfire Games

Petra: Improve relic capturing
ClosedPublic

Authored by Sandarac on May 21 2017, 7:22 PM.

Details

Summary

As suggested in D333, Petra should prioritize capturing gaia relics that are within its territory. While this does not usually happen at game start with the current waythe relics are spawned in the victory condition (the relics are placed in neutral territory unless there are no neutral spawn points), it happens often when the AI gains new territory.

Test Plan

Run some games to test that the AI will capture gaia relics on its territory.

Diff Detail

Repository
rP 0 A.D. Public Repository
Lint
Automatic diff as part of commit; lint not applicable.
Unit
Automatic diff as part of commit; unit tests not applicable.

Event Timeline

Sandarac created this revision.May 21 2017, 7:22 PM
Vulcan added a subscriber: Vulcan.May 22 2017, 2:16 AM

Build is green

Updating workspaces.
Build (release)...
Build (debug)...
Running release tests...
Running cxxtest tests (306 tests)..................................................................................................................................................................................................................................................................................................................OK!
Running debug tests...
Running cxxtest tests (306 tests)..................................................................................................................................................................................................................................................................................................................OK!

http://jw:8080/job/phabricator/1289/ for more details.

mimo added a subscriber: mimo.May 22 2017, 7:38 PM

Thanks for the new patch. I've made some comments inlined.

binaries/data/mods/public/simulation/ai/petra/attackManager.js
504 ↗(On Diff #2090)

This function is a copy of lines 250/260, so if the code stays like that, you should replace these lines by a call to that new function.

But another possibility would be that before the loop on the potential targets from the defenseManager, we do another loop on targets from the gametypeManager (so on targetedRelics) and do the loop on defenseManager.targetList only if nothing is found.

binaries/data/mods/public/simulation/ai/petra/gameTypeManager.js
561 ↗(On Diff #2090)

No more needed if attackManager loops on this.targetedRelics as proposed above

Sandarac updated this revision to Diff 2134.May 22 2017, 7:57 PM

Remove duplicated code for raids, and rename targetEntity function to raidTargetEntity.

Sandarac updated this revision to Diff 2137.May 22 2017, 8:27 PM

Missing semicolon.

Sandarac added inline comments.May 22 2017, 8:31 PM
binaries/data/mods/public/simulation/ai/petra/attackManager.js
504 ↗(On Diff #2090)

I feel rather inclined to keep this code the way it is, so I've removed the duplication in the update function.

Also, targetedRelics consists of relics that currently have an attack plan targeting them, so I'm not sure if the second option you proposed would work.

mimo added a comment.May 22 2017, 8:50 PM

I missed something previously: it is not clear to me if the targetedRelics should only contains gaia relics (which i would support as a raid may not be adapted to fight for an enemy relic) or not: if yes, i've indicated inlined some changes which are needed. If not (i.e. if targetedRelics also contains player relics), we should add a way to remove them if the relic has been moved into enemy territory.

binaries/data/mods/public/simulation/ai/petra/gameTypeManager.js
21 ↗(On Diff #2137)

Do i understand correctly that it contains only gaia relics? if so, this.targetedGaiaRelics would be more explicit

259 ↗(On Diff #2137)

We should also take into account the case where a gaia relic is captured by somebody else, should be removed from this list if only gaia relic in targetedRelics, or should be removed when displaced if all relics in targetedRelics.

557 ↗(On Diff #2137)

do you really want to also target relics which have already been captured by an enemy, but are still in our territory? or only gaia ones?

In D532#21817, @mimo wrote:

I missed something previously: it is not clear to me if the targetedRelics should only contains gaia relics (which i would support as a raid may not be adapted to fight for an enemy relic) or not: if yes, i've indicated inlined some changes which are needed. If not (i.e. if targetedRelics also contains player relics), we should add a way to remove them if the relic has been moved into enemy territory.

Sorry, I wasn't clear :/, targetedRelics indeed only contains gaia relics that have an attack plan assigned to them, so yes, targetedGaiaRelics would be a much better name.

binaries/data/mods/public/simulation/ai/petra/gameTypeManager.js
21 ↗(On Diff #2137)

Yes.

259 ↗(On Diff #2137)

Okay.

557 ↗(On Diff #2137)

I guess it would be more sensible to check only for gaia here.

Build is green

Updating workspaces.
Build (release)...
Build (debug)...
Running release tests...
Running cxxtest tests (306 tests)..................................................................................................................................................................................................................................................................................................................OK!
Running debug tests...
Running cxxtest tests (306 tests)..................................................................................................................................................................................................................................................................................................................OK!

http://jw:8080/job/phabricator/1314/ for more details.

Build is green

Updating workspaces.
Build (release)...
Build (debug)...
Running release tests...
Running cxxtest tests (306 tests)..................................................................................................................................................................................................................................................................................................................OK!
Running debug tests...
Running cxxtest tests (306 tests)..................................................................................................................................................................................................................................................................................................................OK!

http://jw:8080/job/phabricator/1315/ for more details.

Sandarac updated this revision to Diff 2143.May 23 2017, 5:35 AM

Address remarks.

Build is green

Updating workspaces.
Build (release)...
Build (debug)...
Running release tests...
Running cxxtest tests (306 tests)..................................................................................................................................................................................................................................................................................................................OK!
Running debug tests...
Running cxxtest tests (306 tests)..................................................................................................................................................................................................................................................................................................................OK!

http://jw:8080/job/phabricator/1320/ for more details.

mimo added a comment.May 23 2017, 6:52 PM

Thanks for the changes. I've a last inlined comment :) but i can also modify it when commiting (not needed to upload a new pach), just let me know if you agree.

binaries/data/mods/public/simulation/ai/petra/gameTypeManager.js
246 ↗(On Diff #2143)

we should not have this continue if evt.to == PlayerID as we want to add it in criticalEnts.
As there is the continue of line 249/250, it should be enough to remove that line.

Sandarac added inline comments.May 23 2017, 7:07 PM
binaries/data/mods/public/simulation/ai/petra/gameTypeManager.js
246 ↗(On Diff #2143)

Yes, I agree with this change.

mimo accepted this revision.May 23 2017, 7:14 PM

with the one line change requested which will be added when committing

This revision is now accepted and ready to land.May 23 2017, 7:14 PM
This revision was automatically updated to reflect the committed changes.