Seed-able deterministic pseudo random generator for the WebGPU CTS

This generator requires setting a seed value and the sequence of values generated is deterministic based on the seed.

This generator is intended to be a replacement for Math.random().

This generator is not cryptographically secure, though nothing in the CTS should be needing cryptographic security.

The current implementation is based on TinyMT (https://github.com/MersenneTwister-Lab/TinyMT), which is a version of Mersenne Twister that has reduced the internal state size at the cost of shortening the period length of the generated sequence. The period is still 2^127 - 1 entries long, so should be sufficient for use in the CTS, but it is less costly to create multiple instances of the class.

Hierarchy

  • PRNG

Constructors

  • constructor

    Parameters

    • seed: number

      value used to initialize random number sequence. Results are guaranteed to be deterministic based on this. This value must be in the range of unsigned 32-bit integers. Non-integers will be rounded.

    Returns PRNG

Methods

  • Parameters

    • N: number

    Returns number

    a uniformly selected integer in [0, N-1]. N must be at least 1 and at most 2**32.

Generated using TypeDoc