The default SoHL generator: sfc32 (Small Fast Counter), 128-bit state across four 32-bit words. Small, fast, and statistically strong far beyond anything a tabletop system needs (passes PractRand to deep sizes).

All state is held in the four instance fields — no static or shared state, so instances are fully independent and reentrant (see sohl.entity.random.Rng).

mulberry32 is an acceptable single-word fallback if the absolute minimum is ever wanted; it is not needed here. sohl.entity.random.Xoshiro128Rng is the interchangeable alternative behind the same interface.

Hierarchy (View Summary)

Constructors

Methods

  • A uniform die roll in [1, sides].

    Parameters

    • sides: number

      Number of faces; must be >= 1.

    Returns number

    An integer 1 <= n <= sides.

    If sides < 1.

  • Snapshot the internal state so it can be restored with setState (e2e captures before an action, replays after).

    Returns number[]

    A copy of the generator's state words — mutating it is safe.

  • A uniform integer in [min, max], inclusive on both ends.

    Parameters

    • min: number

      Inclusive lower bound.

    • max: number

      Inclusive upper bound; must be >= min.

    Returns number

    An integer min <= n <= max.

    If max < min.

  • Fully reset the stream to a known start (reset, not perturb). String seeds hash through cyrb128, so seeding each unit test with its own name gives an independent, reproducible stream for free.

    Parameters

    • seed: string | number | number[]

      A string, a single number, or the four state words directly.

    Returns void

  • Restore state previously produced by getState. Unlike seed, this sets the exact words with no re-mixing.

    Parameters

    • state: number[]

      The four state words to restore.

    Returns void

    If state does not hold four words.

  • A uniform integer in [0, bound), unbiased (rejection-sampled — no modulo/rounding skew, which matters on d100-scale hit-location tables).

    Parameters

    • bound: number

      Exclusive upper bound; must be >= 1.

    Returns number

    An integer 0 <= n < bound.

    If bound < 1.