diff options
| author | Bobby <[email protected]> | 2026-04-22 06:45:16 +0530 |
|---|---|---|
| committer | Bobby <[email protected]> | 2026-04-22 06:45:16 +0530 |
| commit | 47381ca2cd6dec22848b66924d9558a191e47218 (patch) | |
| tree | c435343184b8d62557cec27127f5371044ab022a /utils/assert/assert.ts | |
| parent | 1e390db8dcde8ef80ea7a86d961a92410cf45e00 (diff) | |
| download | hollowdark-47381ca2cd6dec22848b66924d9558a191e47218.tar.xz hollowdark-47381ca2cd6dec22848b66924d9558a191e47218.zip | |
Implement seeded PRNG with deterministic sub-RNG derivation
rng/ is the load-bearing primitive for simulation determinism
(ARCHITECTURE.md ยง26). All gameplay randomness routes through
createRNG; Math.random is forbidden in gameplay code by ESLint.
rng/derive.ts xmur3 string hash + deriveSeed(parentSeed, label),
stable across processes and runs
rng/seeded.ts SeededRNG interface, mulberry32 implementation,
next / nextInt / nextBool / pick / weightedPick / sub
rng/index.ts public re-exports
Sub-RNG derivation is the key technical move: seeding a child with
hash(parent_seed + label) lets NPCs' trajectories be regenerated
deterministically from their identity tuple alone โ which is how
Tier 3 NPCs stay off-disk until the player needs them.
29 determinism tests in tests/determinism/rng.test.ts cover: same
seed โ same sequence, sub-RNG independence from parent consumption,
sub-order matters, input validation, and a byte-level inline
snapshot that locks the PRNG output for seed "hollowdark". The
snapshot is load-bearing โ if mulberry32 or xmur3 changes, every
existing save diverges, so treat a snapshot break as a migration
concern, not an update-the-snapshot fix.
Diffstat (limited to 'utils/assert/assert.ts')
0 files changed, 0 insertions, 0 deletions
