Deterministic RNG
Seeded pseudo-random number generation.
Mulberry32
cruxOS uses the Mulberry32 algorithm—a fast, high-quality 32-bit PRNG that produces deterministic sequences from a seed.
Usage
const rng = vm.getRNG();
// Get random float [0, 1)
const float = rng.next();
// Get random integer [min, max]
const int = rng.nextInt(1, 10);
// Get random boolean with probability
const bool = rng.nextBool(0.5);
// Pick random element from array
const item = rng.pick(["a", "b", "c"]);Why Not Math.random()?
Math.random() is not deterministic—it produces different
values each run. This breaks the determinism contract.
Never use Math.random() in cruxOS codeSeed Selection
The seed is set in world metadata. Same seed = same random sequence. Use different seeds to explore alternate outcomes.