Repository navigation
Pin mix64, Rng and valueNoise in the determinism test - #21
Conversation
Every generated world and every tick draws from rng.h, but nothing tested it directly: a change there only showed up as a moved fingerprint. The new section pins mix64 against the published SplitMix64 reference outputs, pins the first Rng steps (output and saved state), checks that restoring the state resumes the sequence, that range() is inclusive and below() stays in bounds, and pins valueNoise on the integer lattice (including negative cells) with its midpoint blend, continuity and [0, 1) range. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
There was a problem hiding this comment.
🟢 Approval recommended
No active review issues are reported for this test-only change adding RNG and value-noise characterization coverage.
No open issues 🎉
What changed in this PR
Adds direct characterization tests for the randomness utilities used by world generation and the tick loop, helping pinpoint causes of determinism regressions. No production code or build configuration changes.
Changes:
- Pins
mix64outputs andRngoutputs, state transitions, and state restoration. - Checks inclusive
range()bounds andbelow()bounds. - Pins
valueNoiselattice values and checks midpoint interpolation, cell-edge continuity, and output bounds.
| File | Description |
|---|---|
tests/test_determinism.cpp |
Adds RNG and value-noise checks to the existing determinism test executable. |
Review effort: Balanced
|
Self-review rubric (head
Adversarial note: an exact floating-point equality is used for the lattice and midpoint pins. It holds because at integer coordinates the interpolation weights are exactly 0, and at The Copilot review (COMMENTED, no issues) was received and needs no action. This comment was drafted during a Gardener session (https://github.com/Stephenson-Software/gardener). drafted by Claude on behalf of Daniel Stephenson |
Summary
Stage B (unit-test expansion) cycle targeting
src/colony/rng.h, the source of all randomness in world generation and the tick loop. It had no direct test — a change there was only observable as a moved pinned fingerprint, with no indication of the cause.A new section,
rng: mix64, Rng and valueNoise are pinned and in range, is added totests/test_determinism.cpp(kept in an existing executable soCMakeLists.txtis untouched):mix64is pinned against the published SplitMix64 reference outputs for seed 0 (0xe220a8397b1dcdaf,0x6e789e6aa1b965f4) — an independent reference, not a value read back from this code.Rng{12345}.next()outputs and the resultingstateare pinned (the state is whatGlobals::rngsaves), and a copy built from a mid-sequence state is checked to resume identically.range(-3, 3)is checked to be inclusive at both ends over 2,000 draws;below(7)stays in[0, 7)andbelow(1)is always 0.valueNoiseis pinned exactly on the integer lattice (as 53-bit integers after scaling by 2^53, including a negative cell and a second seed), checked to blend to the exact midpoint atx + 0.5, to be continuous across a cell edge, and to stay in[0, 1)over a 40×40 sample including negative coordinates.These are characterization tests: no production code is changed. The expected integer values were computed independently with Python's arbitrary-precision integers following the same arithmetic as
rng.h.Save-integrity notes: no schema, bridge,
strata.refor component change; the pinned rules fingerprint is unchanged; no existingCHECKis removed.Test plan
rules (gcc-13),rules (clang-18),rules (asan-ubsan),rules (msvc)green on the head SHA (this is the anchor — the local sandbox deniedcmake/g++, so the change is UNVERIFIED locally)game on Strata (saves soak, headless smoke)greendeterminismtest output shows the new section withALL PASSEDNo tracking issue — the gap was found during triage (no open issues existed).
This PR description was drafted during a Gardener session (https://github.com/Stephenson-Software/gardener).
drafted by Claude on behalf of Daniel Stephenson