devilutionX icon indicating copy to clipboard operation
devilutionX copied to clipboard

Introduce xoshiro RNG to generate dungeon seeds

Open StephenCWills opened this issue 1 year ago • 1 comments

Implements the technique for mitigating overlapping random number sequences described in https://github.com/diasurgical/devilutionX/pull/6438#discussion_r1285147193.

Summary of changes:

  • Introduce the xoshiro128++ RNG
  • Rename GenerateSeed() to GenerateRandomNumber()
  • Use xoshiro128++ to reimplement GenerateSeed()
  • Rename GameData::dwSeed to GameData::gameSeed
  • Use 64 bits for the game seed and use std::chrono to generate it
  • Update logic for generating dungeon seeds using xoshiro128++ instead of LCG

The 32-bit overload for xoshiro128plusplus::seed() is intended to provide a way to reseed xoshiro128++ using a dungeon seed. This will become necessary to create a deterministic sequence of seeds for monsters, objects, and items during dungeon generation. It feels a bit like falling back on old habits to use this random number generator to seed itself, but the SplitMix32 implementation makes it work.

This replaces #6438 This resolves #6261

StephenCWills avatar Mar 17 '24 06:03 StephenCWills

Assuming this PR makes it into 1.6, don't forget to merge https://github.com/diasurgical/devilutionx-gamelist/pull/27 and update the Discord bot at some point before the release.

StephenCWills avatar Mar 22 '24 22:03 StephenCWills