Page MenuHomeWildfire Games

Petra: assign guards to the hero in regicide games
ClosedPublic

Authored by Sandarac on Feb 23 2017, 3:38 AM.

Details

Summary

Petra will assign military units as guards to the hero in the regicide victory condition, preferring any available Champion units.

Also this diff fixes a broken loop through a Map in D140/rP19226 that was introduced when switching criticalEnts.guards from a Set to a Map.

With this, the "Regicide AI support" ticket can be closed.

Test Plan

Check that Petra correctly assigns a mix of military units and healer units as guards to the hero in regicide games.

For a bit more extensive test, to verify that the diff doesn't break existing functionality:

  1. Start a single-player regicide game on the random map "Aegean Sea" with one AI player.
  2. The AI should assign some citizen-soldiers to the hero once it has a large-enough population.
  3. When the AI has built a ship, change the perspective to the AI player and garrison the hero on the ship, which will cause the guard units to be unassigned.
  4. Ungarrison the hero on a different access index, which will cause the guard units to be transported and reassigned to the hero.

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.Feb 23 2017, 3:38 AM
Vulcan added a subscriber: Vulcan.Feb 23 2017, 4:35 AM

Build is green

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

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

mimo added a subscriber: mimo.Feb 23 2017, 10:22 PM

Patch looks good, and i'll commit it after the update turn is fixed.
But, for a next patch, i think your numbers of assigned guards should vary more depending on the economy status of the AI: if the AI has suffered some attacks and its pop has decreased, it is really a waste to keep too much soldiers inactive guarding while they could help the ai to recover. Not a problem for champions, but the number of soldiers should be more dynamic, adjustable to the available workforce and resource needs.

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

nice fix!

454 ↗(On Diff #582)

this loop could also be done only if playedTurn%10 === 0 (a possibility is also that each loop run on a different turn, with playedTurn%10 === k and k different on each loop).

Sandarac updated this revision to Diff 591.Feb 24 2017, 7:49 AM

Update so that Petra only checks for the stance of any heroes when playedTurn % 10 === 0.

Hello mimo, thanks for the quick response,

In D157#6081, @mimo wrote:

But, for a next patch, i think your numbers of assigned guards should vary more depending on the economy status of the AI: if the AI has suffered some attacks and its pop has decreased, it is really a waste to keep too much soldiers inactive guarding while they could help the ai to recover. Not a problem for champions, but the number of soldiers should be more dynamic, adjustable to the available workforce and resource needs.

Yes, this is a good idea. I guess in order to do this, when manageCriticalEntGuards is called, it would first check the population, and if it is less than something like 30, it would remove any citizen-soldier guards so that they could be used for other tasks.

Build is green

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

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

mimo added a comment.Feb 24 2017, 7:00 PM
In D157#6099, @Sandarac wrote:

Yes, this is a good idea. I guess in order to do this, when manageCriticalEntGuards is called, it would first check the population, and if it is less than something like 30, it would remove any citizen-soldier guards so that they could be used for other tasks.

Yes, that should do the job.

mimo added a comment.Feb 24 2017, 7:13 PM
In D157#6097, @Sandarac wrote:

Update so that Petra only checks for the stance of any heroes when playedTurn % 10 === 0.

I guess you misunderstood my previous comment: it was not about changing the frequency of stance checks (which was already not each turn), but to change the frequency of the healers check which is done every turn. I'll change that when commiting (also merging the two loops). Let me know if you disagree :-)

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

could be merged with the loop of line 447, as we don't need to check it on every turn.

This revision was automatically updated to reflect the committed changes.
In D157#6163, @mimo wrote:
In D157#6097, @Sandarac wrote:

Update so that Petra only checks for the stance of any heroes when playedTurn % 10 === 0.

I guess you misunderstood my previous comment: it was not about changing the frequency of stance checks (which was already not each turn), but to change the frequency of the healers check which is done every turn. I'll change that when commiting (also merging the two loops). Let me know if you disagree :-)

Oh, sorry, yes I misunderstood, thanks for fixing that.