Page MenuHomeWildfire Games

Initialize AIManager RNG Seed in Simulation2, not JS
ClosedPublic

Authored by elexis on Dec 26 2017, 10:41 PM.

Details

Summary

As described in #4907 and discovered by mimo in D1159, the AISeed from rP15973 is initialized a bit too late in InitGame of simulation/helpers/InitGame.js.
So the Config function in config.js of the bot does not use the intended RNG seed.

To remove the possibility that a statement is inserted in some JS code prior to the Seed initialization, the Seed can be initialized immediately in C++ once the Simulation2 is aware of the setting.
It can be done the same way as it is done for the Seed.

Test Plan

Notice the code symmetry. One can add debug_printf and warn to these functions to see the execution order.

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

elexis created this revision.Dec 26 2017, 10:41 PM
Vulcan added a subscriber: Vulcan.Dec 27 2017, 12:21 AM

Successful build - Chance fights ever on the side of the prudent.

Updating workspaces...
Build (release)...
Build (debug)...
Running release tests...
Running cxxtest tests (308 tests)....................................................................................................................................................................................................................................................................................................................OK!
Running debug tests...
Running cxxtest tests (308 tests)....................................................................................................................................................................................................................................................................................................................OK!
Checking XML files...
Executing section Default...
Executing section Source...
Executing section JS...
mimo accepted this revision.Dec 27 2017, 4:30 PM

Patch is good, and works as expected

This revision is now accepted and ready to land.Dec 27 2017, 4:30 PM

Thanks for the review!

This revision was automatically updated to reflect the committed changes.
Owners added a subscriber: Restricted Owners Package.Dec 27 2017, 5:51 PM