PARACOSM AGENTOS | API Reference v0.9.1202
Home Simulation API Docs GitHub npm
Home Simulation API Docs GitHub npm AgentOS Discord
paracosm - v0.9.1202
    Preparing search index...

    Class SeededRng

    Mulberry32: fast 32-bit seeded PRNG. Deterministic: same seed always produces same sequence.

    Index
    • Returns true with the given probability (0-1).

      Parameters

      • probability: number

      Returns boolean

    • Current PRNG state, as a 32-bit integer. Captured into snapshots and restored via fromState for deterministic resume.

      Returns number

    • Returns an integer in [min, max] inclusive.

      Parameters

      • min: number
      • max: number

      Returns number

    • Picks a random element from an array.

      Type Parameters

      • T

      Parameters

      • arr: readonly T[]

      Returns T

    • A stream of its own for one draw: one person, one cause, one turn. The state is the FNV-1a 32-bit hash of turn:agentId:cause XOR the run's seed, so two runs with the same seed roll the same dice for the same person whatever else happened in them, and no other person's draw moves it.

      Parameters

      • seed: number
      • turn: number
      • agentId: string
      • cause: string

      Returns SeededRng

    • The one die a person keeps for a cause of death for their whole life, in a run whose scenario keeps one death die for a life (setup.mortalityDice: 'life'): keyed by the seed, the person and the cause, and by no turn or year.

      Parameters

      • seed: number
      • agentId: string
      • cause: string

      Returns SeededRng

    • Construct a SeededRng positioned at a specific internal state. Different from the seed-based constructor: the returned RNG produces the same sequence as the source did AT THE MOMENT getState() was captured.

      Parameters

      • state: number

      Returns SeededRng