MantisBT - VCMI
View Issue Details
0002583VCMIMultiplayerpublic2016-10-30 22:302024-11-14 21:58
SXX 
Ivan 
normalmajoralways
closedfixed 
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
2024-11-14 21:58IvanNote Added: 0008987
2024-11-14 21:58IvanStatusnew => closed
2024-11-14 21:58IvanAssigned To => Ivan
2024-11-14 21:58IvanResolutionopen => fixed

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.
(0008987)
Ivan   
2024-11-14 21:58   
No longer relevant - RMG is server-only now