Concepts

Determinism

The foundational principle of cruxOS.

The Determinism Contract
same IR + same seed = same world evolution

What is Determinism?

A deterministic system always produces the same output given the same input. In cruxOS, this means running a world with identical initial conditions will always produce identical results—every tick, every event, every outcome.

Why It Matters

  • Reproducibility — Debug by replaying exact scenarios
  • Verification — Prove outcomes are legitimate
  • Sharing — Exchange seeds instead of full histories
  • Testing — Write predictable test cases

Seeded RNG

cruxOS uses a Mulberry32 PRNG. The seed in your world metadata initializes this generator, making "random" events predictable.

// ❌ Never use Math.random()
const bad = Math.random();

// ✅ Use the VM's seeded RNG
const good = vm.getRNG().next();