[Minor Feature] Per-call RNG sites still generate an unrecorded seed when seed=None (procgen, sfxr) #408
Labels
No labels
Alpha Release Requirement
Bugfix
Demo Target
Documentation
Major Feature
Minor Feature
priority:tier1-active
priority:tier2-foundation
priority:tier3-future
priority:tier4-deferred
Refactoring & Cleanup
system:animation
system:documentation
system:grid
system:input
system:performance
system:procgen
system:python-binding
system:rendering
system:ui-hierarchy
Tiny Feature
workflow:blocked
workflow:needs-benchmark
workflow:needs-documentation
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
john/McRogueFace#408
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Follow-up to #394, which fixed the two RNGs that had no seed parameter at all
(
EntityBehavior.cpp,PySound::py_play_varied). It deliberately did not touch the sites thatalready accept an explicit seed, because those are a different shape and a different fix.
Those sites are still not replayable when the caller passes nothing, which is the common case:
seed=NonePySoundBuffer::sfxrstd::random_device rd; rng.seed(rd())— generated, not recorded, not readable backPySoundBuffer::sfxr_mutatePyBSP::split_recursivenullptrtoTCOD_bsp_split_recursive, i.e. libtcod's global default RNG — not recordable at all from PythonPyHeightMap(CreateTCODRandom)nullptr→ libtcod's global default RNG, used byadd_hill,dig_hill,mid_point_displacementetc.PyNoiseSourceis the counter-example and the model: it generates a seed when given none, recordsit, and exposes it as a read-only
seedproperty.Two consequences worth separating:
bsp.split_recursive(depth=5)cannot be regenerated,even in principle, because the seed it used is not recoverable. Same for a procedural sound.
interleave and neither is reproducible on its own even if you did know the seed.
Separately and in the same family:
src/audio/SfxrSynth.cppsfxr_synthesize()callsstd::srand(42)unconditionally and draws withstd::rand(). That makes sfxr itself deterministic,but it clobbers the process-global C
rand()state as a side effect of synthesising a sound —any other consumer of
rand()in the process is silently reset.Suggested shape, matching
PyNoiseSourceand #394: whenseed=None, draw the seed from the engine'sseeded stream (
mcrf::EngineRandom) rather than fromstd::random_device/libtcod's global, andrecord it on the resulting object so it can be read back. That makes the whole engine replayable from
one
mcrfpy.set_random_seed()without changing any call site.