MantisBT - VCMI
View Issue Details
0002583VCMIMultiplayerpublic2016-10-30 22:302017-05-22 22:08
SXX 
 
normalmajoralways
newopen 
0.98g 
 
0002583: Multiplayer: RNG distribution is not consistent between compilers / platforms
Today we tested some MP with dydzio and one thing we find out is that map init could desync even if seed perfectly match. We use "mt19937" and it's do it's just very well.

While I did very little research it's looks like std distribution functions don't have deterministic results across platforms and compilers.
No tags attached.
Issue History
2016-10-30 22:30SXXNew Issue
2017-03-15 21:30DydzioNote Added: 0006984
2017-03-16 17:28WarmongerNote Added: 0006985
2017-03-17 09:43DydzioNote Added: 0006987
2017-03-19 02:48SXXNote Added: 0006995
2017-05-22 22:02SXXFile Added: 10M.zip
2017-05-22 22:08SXXFile Added: 20M.zip
2017-05-22 22:08SXXFile Deleted: 20M.zip
2017-05-22 22:08SXXFile Deleted: 10M.zip

Notes
(0006984)
Dydzio   
2017-03-15 21:30   
http://stackoverflow.com/questions/34903356/c11-random-number-distributions-are-not-consistent-across-platforms-what-al [^]

Seems we need to write custom consistent distribution (best way imo) or use boost or equivalent like http://www.pcg-random.org/ [^] for random number generation.
(0006985)
Warmonger   
2017-03-16 17:28   
Where exatly do we use random distributions? I don't remember any case, so probably it's not that important part after all.
(0006987)
Dydzio   
2017-03-17 09:43   
@Warmonger

Check lib/CRandomGenerator.cpp -> CRandomGenerator::getIntRange for example.

There are some typedefs used, defined at the top of lib/CRandomGenerator.h
(0006995)
SXX   
2017-03-19 02:48   
Keep in mind that integers are not problem there, but float are.