Dwarf Fortress Bug Tracker - Dwarf Fortress
View Issue Details
0006379Dwarf FortressMiscellaneous Crashespublic2013-09-30 05:482014-07-26 14:15
Quietust 
Toady One 
normalmajorhave not tried
resolvedfixed 
0.34.11 
0.40.05 
0006379: Double-seed and triple-seed RNG init functions do not work correctly, causing inconsistent world gen
g_src/random.cpp contains 3 functions for initializing a particular random number generator (there are 10 total), initializing the first entry of the specified mt_buffer with the specified seed and then using that value to initialize the rest of mt_buffer.

However, the double-seed and triple-seed variants are broken - their loops start at i=0, causing the first entry to be overwritten with data calculated from memory before the beginning of the buffer (b[-1]). The uniform-seed variant does not have this problem, since its loop starts at i=1.
No tags attached.
related to 0005974new  Seeds do not generate same worlds between different OSs 
related to 0005633new  TITLE Changes Large Region History, Also Something Else Unknown 
Issue History
2013-09-30 05:48QuietustNew Issue
2013-09-30 05:55QuietustNote Added: 0024147
2013-09-30 10:00FootkerchiefNote Added: 0024148
2013-09-30 11:37QuietustNote Added: 0024149
2013-09-30 12:32FootkerchiefRelationship addedrelated to 0005633
2013-09-30 12:32FootkerchiefSummaryDouble-seed and triple-seed RNG init functions do not work correctly => Double-seed and triple-seed RNG init functions do not work correctly, resulting in inconsistent world gen
2013-09-30 12:32FootkerchiefSummaryDouble-seed and triple-seed RNG init functions do not work correctly, resulting in inconsistent world gen => Double-seed and triple-seed RNG init functions do not work correctly, causing inconsistent world gen
2013-09-30 12:33FootkerchiefRelationship addedrelated to 0005974
2013-09-30 12:41QuietustNote Added: 0024150
2013-09-30 23:20agNote Added: 0024151
2014-07-26 14:15Toady OneStatusnew => resolved
2014-07-26 14:15Toady OneFixed in Version => Next Version
2014-07-26 14:15Toady OneResolutionopen => fixed
2014-07-26 14:15Toady OneAssigned To => Toady One

Notes
(0024147)
Quietust   
2013-09-30 05:55   
Analysis of a disassembly reveals that the triple-seed variant is being used within the game itself, being called 4 times from a single function, while the double-seed variant does not appear to be used at all (and the uniform-seed variant comes up with 26 references).
(0024148)
Footkerchief   
2013-09-30 10:00   
What are the in-game implications?
(0024149)
Quietust   
2013-09-30 11:37   
Explicit random number seeds, such as those used during worldgen, may not produce consistent results where intended.
(0024150)
Quietust   
2013-09-30 12:41   
I did perform a few worldgen tests on Windows using custom seeds, and while they did appear to have consistent results (and modifying one seed caused only things related to that seed to change), the worlds were not strictly identical (though these differences may be due to randomness which isn't drawn from any of the worldgen seeds).
(0024151)
ag   
2013-09-30 23:20   
Also, I would imagine that just adding up the three seed values and storing them into the same unsigned int field would not introduce any more entropy than just one 32-bit integer value. Instead, the values should be stored into 3 independent locations in the array, and the rest filled accordingly - preferrably interleaving 3 pseudo-random sequences starting from the seeds.