Repository navigation
Conversation
…uses -seed only seeded the main RNG. RandomRange instances (seeded from a separate generator before tables parse) and the std::random_device shuffles of weapon firepoints, asteroid splits and random-message senders stayed unseeded, so two runs with the same seed could diverge from the first frame. - Random::seed_ranges() seeds the generator that RandomRange instances draw from. - game_init() seeds both families when -seed is given, before table parsing. - Random::shuffle_seed() gives each std::shuffle its generator seed: a draw from the seeded main RNG under -seed, OS entropy otherwise (normal gameplay is unchanged). The ship firepoint, asteroid-split and message-sender shuffles use it instead of three separate std::random_device sites. In multiplayer the main RNG is seeded from the netgame and -seed is ignored, so the shuffles keep using OS entropy there and the shared sequence is unchanged. RandomRange instances are seeded once, when they are created (mostly while the tables are parsed), so a mission restarted in the same process does not repeat their draws. Reproducible runs need one process per run.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Split out of #7874.
-seedonly seeded the main RNG. The generator thatRandomRangeinstances draw their seeds from was seeded fromstd::random_device, and the ship firepoint, asteroid-split and random-message-sender shuffles each created a freshstd::random_device, so two runs with the same seed could diverge from the first frame.Random::seed_ranges()seeds the generatorRandomRangeinstances take their seeds from;game_init()calls it, with the main RNG, before the tables are parsed when-seedis given.Random::shuffle_seed()gives eachstd::shuffleits seed: a draw from the main RNG under-seed, OS entropy otherwise. The threestd::random_devicesites use it.Without
-seednothing changes: the main RNG is seeded from the time as before, and the shuffles still use OS entropy.Multiplayer seeds the main RNG from the netgame and ignores
-seed, so the shuffles keep using OS entropy there and the shared sequence is not consumed differently on one machine.Known limit:
RandomRangeinstances are seeded once, when they are created (mostly while the tables are parsed), so a mission restarted in the same process does not repeat their draws. Reproducible runs need one process per run. Making restarts repeat would need every instance reseeded, which is a separate change.Testing: headless runs of a retail mission with seeds 77, 77, 78, 78 gave identical end states (positions, hull totals) for equal seeds and different ones for different seeds. Each changed file compiles on this branch alone; the combined branches build with
FSO_FATAL_WARNINGS=ONon Windows (MSVC) and Linux (gcc-13, clang-16), and the unit tests pass.