Page MenuHomeWildfire Games

Petra: Account for relics and wonder in last man standing mode
ClosedPublic

Authored by Sandarac on May 20 2017, 8:53 PM.

Details

Summary

As suggested in D236, Petra should account for these entities when picking a player to become enemies with in last man standing.

The key to this diff is deciding exactly how to increase the turnFactor, as Petra is supposed to be more inclined to turn against neutral players first before allies.

Test Plan

Read the code.

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 20 2017, 8:53 PM
Vulcan added a subscriber: Vulcan.May 21 2017, 1:05 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/1275/ for more details.

mimo added a subscriber: mimo.May 21 2017, 7:25 PM
mimo added inline comments.
binaries/data/mods/public/simulation/ai/petra/diplomacyManager.js
254 ↗(On Diff #2058)

Shouldn't we continue the loop and check if there is another player with also a wonder more advanced in the countdown, instead of choosing the first one with a built wonder?

265 ↗(On Diff #2058)

If keeping it that way, I would change it to "turnFactor *= 1 + relicsCount;" so that already 1 relic gives more chance to be chosen

but i wonder if you shouldn't do as for wonder, i.e. use a constant penalty rather than one depending on the number of units, so

turnFactor += relicsCount * 150;

because if you have two allies, one with 151 units and one with 50 units and 2 relics, i would rather choose the latter first.

And finally, as 150 is used several times, could be a parameter (defined either at the top of this function or in the config file, could also be changed to something like maxPop/2 if that's how you've tuned it).

Thanks mimo for the remarks!

binaries/data/mods/public/simulation/ai/petra/diplomacyManager.js
254 ↗(On Diff #2058)

Well, this check for wonderProgress is based off of the one in getEnemyPlayer in attackManager, which also breaks at the first wonder found with an undefined foundationProgress (I've found that it is usually a good idea to follow such patterns that exist in the code already). And in any case, I don't believe there is a way to check for a wonder with a more advanced countdown once it has been built, and even if such a way was added, this may be taking the AI too far (and it becomes "cheating" in a sense). So I'm tending to believe this isn't needed.

265 ↗(On Diff #2058)

Okay.

Also I forgot to use the updatingGlobalCollection "allRelics" instead, so I will use that instead.

mimo added inline comments.May 21 2017, 7:59 PM
binaries/data/mods/public/simulation/ai/petra/diplomacyManager.js
254 ↗(On Diff #2058)

It's quite a long time I've played with wonder, but iirc the countdown is displayed for all users (maybe not as soon as the wonder is built, but once it reaches some limit), so i don't think it would be cheating :)

But i'm also fine with keeping the code as is. The real solution will then to ensure that, when a countdown is displayed for all users, this info is sent to the ai and, and when such a countdown is running, the ai chooses the enemy with the more advanced countdown. But that looks like a next patch.

mimo accepted this revision.May 21 2017, 8:07 PM

Looks good

This revision is now accepted and ready to land.May 21 2017, 8:07 PM
This revision was automatically updated to reflect the committed changes.

Build has FAILED

Link to build: http://jw:8080/job/phabricator/1290/
See console output for more information: http://jw:8080/job/phabricator/1290/console