View Issue Details

IDProjectCategoryView StatusLast Update
0006379Dwarf FortressMiscellaneous Crashespublic2014-07-26 14:15
ReporterQuietust Assigned ToToady One  
PrioritynormalSeveritymajorReproducibilityhave not tried
Status resolvedResolutionfixed 
Product Version0.34.11 
Fixed in Version0.40.05 
Summary0006379: Double-seed and triple-seed RNG init functions do not work correctly, causing inconsistent world gen
Descriptiong_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.
TagsNo tags attached.

Relationships

related to 0005974 new Seeds do not generate same worlds between different OSs 
related to 0005633 new TITLE Changes Large Region History, Also Something Else Unknown 

Activities

Quietust

2013-09-30 05:55

reporter   ~0024147

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).

user6

2013-09-30 10:00

  ~0024148

What are the in-game implications?

Quietust

2013-09-30 11:37

reporter   ~0024149

Explicit random number seeds, such as those used during worldgen, may not produce consistent results where intended.

Quietust

2013-09-30 12:41

reporter   ~0024150

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).

ag

2013-09-30 23:20

reporter   ~0024151

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.

Issue History

Date Modified Username Field Change
2013-09-30 05:48 Quietust New Issue
2013-09-30 05:55 Quietust Note Added: 0024147
2013-09-30 10:00 user6 Note Added: 0024148
2013-09-30 11:37 Quietust Note Added: 0024149
2013-09-30 12:32 user6 Relationship added related to 0005633
2013-09-30 12:32 user6 Summary Double-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:32 user6 Summary Double-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:33 user6 Relationship added related to 0005974
2013-09-30 12:41 Quietust Note Added: 0024150
2013-09-30 23:20 ag Note Added: 0024151
2014-07-26 14:15 Toady One Status new => resolved
2014-07-26 14:15 Toady One Fixed in Version => Next Version
2014-07-26 14:15 Toady One Resolution open => fixed
2014-07-26 14:15 Toady One Assigned To => Toady One