Expose versioned deterministic random stream state and portable bounded draws #10

Closed
opened 2026-12-02 19:24:05 +00:00 by faumaray · 1 comment
Owner

An application that saves a simulation partway through a random stream needs to resume at the next draw. A seed alone requires replaying every earlier draw. Parallel generation also needs independent, explicitly owned streams whose results survive changes to worker scheduling.

At 7b0fea6095f603f9e1904f66dfdc7752f4be4792, Void::Random::Xoshiro256 has an explicit seeded constructor, a raw integer call operator and linear-time discard. Its complete state is private. The public bounded integer convenience API uses a thread-local generator and a standard-library distribution. The tests compare the first values of two generators in the same process. Public header · Existing tests

Would the library accept a public, versioned state representation for an explicitly owned reproducible integer generator, with checked export/import and a specified bounded-integer mapping? The algorithm identity and state word order should let consumers specify their own wire format. Our current generated prototype terrain uses SplitMix64. We can retain that generator for historical worlds and adopt a different documented algorithm only under a new generator version. Current consumer · Voxel generation and versioning

A replacement check would freeze raw and bounded outputs for a fixed seed on Windows x64 and a second target. Save after mixed raw and bounded draws, restore in a fresh process, and compare the uninterrupted suffix word for word. Interleave two caller-owned streams, test zero/one and large non-power-of-two bounds with a documented zero-bound policy, and reject malformed, unknown-version or invalid all-zero Xoshiro state without changing the existing stream.

An application that saves a simulation partway through a random stream needs to resume at the next draw. A seed alone requires replaying every earlier draw. Parallel generation also needs independent, explicitly owned streams whose results survive changes to worker scheduling. At `7b0fea6095f603f9e1904f66dfdc7752f4be4792`, `Void::Random::Xoshiro256` has an explicit seeded constructor, a raw integer call operator and linear-time `discard`. Its complete state is private. The public bounded integer convenience API uses a thread-local generator and a standard-library distribution. The tests compare the first values of two generators in the same process. [Public header](https://git.faumaray.com/Void/Library/src/commit/7b0fea6095f603f9e1904f66dfdc7752f4be4792/include/Void/Math/Random.hpp) · [Existing tests](https://git.faumaray.com/Void/Library/src/commit/7b0fea6095f603f9e1904f66dfdc7752f4be4792/tests/standalone/Math/Random.cpp) Would the library accept a public, versioned state representation for an explicitly owned reproducible integer generator, with checked export/import and a specified bounded-integer mapping? The algorithm identity and state word order should let consumers specify their own wire format. Our current generated prototype terrain uses SplitMix64. We can retain that generator for historical worlds and adopt a different documented algorithm only under a new generator version. [Current consumer](https://git.faumaray.com/Lagg1ng/stoneheart_at_home/src/commit/2a5df1a18b055adc71bd9d3defe2bec40c4496e7/engine/include/settlement/core/deterministic_rng.hpp) · [Voxel generation and versioning](https://git.faumaray.com/Lagg1ng/stoneheart_at_home/src/commit/2a5df1a18b055adc71bd9d3defe2bec40c4496e7/docs/plan/systems/S02.md) A replacement check would freeze raw and bounded outputs for a fixed seed on Windows x64 and a second target. Save after mixed raw and bounded draws, restore in a fresh process, and compare the uninterrupted suffix word for word. Interleave two caller-owned streams, test zero/one and large non-power-of-two bounds with a documented zero-bound policy, and reject malformed, unknown-version or invalid all-zero Xoshiro state without changing the existing stream.
Author
Owner

Implemented on branch issue/10-versioned-rng-state (commit 2e8afc4).

Xoshiro256 now exposes a versioned public state with checked restore and an unbiased bounded() draw with a documented zero-bound policy.

Branch: https://git.faumaray.com/Void/Library/src/branch/issue/10-versioned-rng-state
Merge request: https://git.faumaray.com/Void/Library/pulls/new/issue/10-versioned-rng-state

Implemented on branch `issue/10-versioned-rng-state` (commit `2e8afc4`). `Xoshiro256` now exposes a versioned public state with checked restore and an unbiased `bounded()` draw with a documented zero-bound policy. Branch: https://git.faumaray.com/Void/Library/src/branch/issue/10-versioned-rng-state Merge request: https://git.faumaray.com/Void/Library/pulls/new/issue/10-versioned-rng-state
Sign in to join this conversation.
No labels
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: Void/Library#10