In testing out code changes I load a moderator-mode multiplayer game I have previously saved at turn 1, and then let it progress and see how things go. There is a problem though in that even with no code changes I will not get identical results from replaying a game multiple times in that fashion. One spot that looks to me like a lapse in the SVN codebase is that the RNG state is not immediately set upon loading a savegame; it looks like it doesn't get set until a combat round and so the initial rounds of Effects processing could be done with the RNG in an unknown state. I tried changing that, though, so that starting a game loaded from a file would also set the RNG to the galaxy creation seed, but that did not solve the problem for me; I still got highly variable results. I just now went ahead and committed that code change though since I think it is at least a helpful step towards getting fully consistent results.
Every turn the AI's each right away set their RNG seed according to a combination of galaxy_seed, current_turn, and empire_id, so I don't think the problem is there.
If anyone can help figure this problem out it would be greatly appreciated and would allow me to do much better testing of the AI.
consistent RNG after save game load
Moderator: Committer
consistent RNG after save game load
If I provided any code, scripts or other content here, it's released under GPL 2.0 and CC-BY-SA 3.0
- Geoff the Medio
- Programming, Design, Admin
- Posts: 13587
- Joined: Wed Oct 08, 2003 1:33 am
- Location: Munich
Re: consistent RNG after save game load
There might be unavoidable randomness due to the order in which AIs execute their turns. If they're requesting object IDs from the server in a random order, objects will get different IDs between playthroughs. I think IDs get used in randomizing battle results, and probably various other things during turn processing.
Re: consistent RNG after save game load
good points, thanks.
If I provided any code, scripts or other content here, it's released under GPL 2.0 and CC-BY-SA 3.0
- Geoff the Medio
- Programming, Design, Admin
- Posts: 13587
- Joined: Wed Oct 08, 2003 1:33 am
- Location: Munich
Re: consistent RNG after save game load
One could possibly attempt to allocate object IDs to empires (and non-empire objects) from separate pools, possibly eliminating that order-dependence.
Re: consistent RNG after save game load
hmm. It could be, in that case, that we'd want the relationship between object ids and requesting empire to be opaque so that players couldn't glean (original) empire ownership from the mere object ID even if they don't have sufficient visibility to get owner id. But I'm not recalling when an Empire might request anything other than a new Fleet ID, and under what circumstances that original ownership might then need to be hidden, so perhaps the whole thing might not need to be so opaque.
I'll bookmark this for now, since I don't really have enough time available right now to think that through properly.
I'll bookmark this for now, since I don't really have enough time available right now to think that through properly.
If I provided any code, scripts or other content here, it's released under GPL 2.0 and CC-BY-SA 3.0