Skip to Content
defold-typescript libraries
alchimystic

alchimystic/defold-rng/rng

Factory of random number generator instances (non-global) for specific algorithms. Supports pcg32

  • GitHub: alchimystic/defold-rng — pinned to v1.3.0 (released while Defold 1.14.0 was current)
    1. Pick a release from alchimystic/defold-rng releases and add its Source code (zip) URL (or a packaged .zip asset, if the library ships one) to game.project under [project] dependencies, then Fetch Libraries in the Defold editor.
    2. Run bunx @defold-typescript/cli resolve to materialize its types.
    3. Import it under a namespace alias of your choice:
      import * as rnd from "rnd"
  • Asset Portal: defold-rng

Functions

rnd.pcg32(init_state: number, init_seq: number)

Creates a pcg32 instance. Can specify init_state and init_seq to start with a seed, or nothing to get a random one

Parameters

  • init_state: number — init_state is the starting state for the PCG32, you can pass any 64-bit value.
  • init_seq: number — init_seq selects the output sequence for the PCG32, you can pass any 64-bit value, although only the low 63 bits are significant.

On this page