[PATCH] Actually initialize random number generator seed in the simulation
|Reported by:||elexis||Owned by:||elexis|
|Priority:||Must Have||Milestone:||Alpha 21|
- With Regicide mode, the same hero is spawned everytime on the map
Math.random()delivers the same number everytime on that map, different ones on other maps
- Reducing elements from anatolian plateau leads to repeated random numbers instead of different ones every generation
Currently the simulation doesn't initialize the seed for the (custom)
Math.random() function being set in the
ComponentManager.cpp, see this TODO:
// TODO: ought to seed the RNG (in a network-synchronised way) before we use it
There are three different RNGs: in the
MapGenerator. As they are defined in individual scriptinterfaces / contexts, they ought to be independent from each other.
However the observation doesn't match this. Apparently the mapgeneration randomness seeds the simulation randomness too.
Either way the seed should be set and could just reuse the seed determined in
g_GameAttributes.settings.Seed = Math.floor(Math.random() * 65536);
Also the code should at least use 32bit, not 16bit random numbers while at it.
One could implement a different seed for both map generation and simulation. That however would complicate the implementation (atlas) and debugging without any real benefit.
Not sure (yet?) on how to test that the random numbers returned are actually random.