Mantis Bug Tracker

View Issue Details Jump to Notes ] Issue History ] Print ]
IDProjectCategoryView StatusDate SubmittedLast Update
0006379Dwarf FortressMiscellaneous Crashespublic2013-09-30 05:482014-07-26 14:15
ReporterQuietust 
Assigned ToToady One 
PrioritynormalSeveritymajorReproducibilityhave not tried
StatusresolvedResolutionfixed 
PlatformOSOS Version
Product Version0.34.11 
Target VersionFixed 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.
Attached Files

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

-  Notes
(0024147)
Quietust (reporter)
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 (manager)
2013-09-30 10:00

What are the in-game implications?
(0024149)
Quietust (reporter)
2013-09-30 11:37

Explicit random number seeds, such as those used during worldgen, may not produce consistent results where intended.
(0024150)
Quietust (reporter)
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 (reporter)
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.

- 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 Footkerchief Note Added: 0024148
2013-09-30 11:37 Quietust Note Added: 0024149
2013-09-30 12:32 Footkerchief Relationship added related to 0005633
2013-09-30 12:32 Footkerchief 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 Footkerchief 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 Footkerchief 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


Copyright © 2000 - 2010 MantisBT Group
Powered by Mantis Bugtracker