Pseudo-random number generator.

interface Random {
    getModulus(): number;
    getSeed(): number;
    nextFloat(): number;
    nextInt(): number;
    nextRange(n): number;
    randomInts(n): number[];
    setSeed(seed): void;
}

Implemented by

Methods

  • Returns the modulus of the random number generator.

    Returns number

    the modulus of the random number generator

  • Returns the seed of the random number generator.

    Returns number

    the seed of the random number generator

  • Returns random floating point number in range [0,1].

    Returns number

    random floating point number in range [0,1]

  • Returns next random integer in range 0 (inclusive) to modulus (exclusive).

    Returns number

    next the pseudo-random number

  • Returns random integer in range 0 (inclusive) to n (exclusive).

    Parameters

    • n: number

      the limit of the range

    Returns number

    random integer in range 0 (inclusive) to n (exclusive)

  • Returns an array of integers from 0 to n-1, in random order.

    Parameters

    • n: number

      the size of the array to create

    Returns number[]

    an array of integers from 0 to n-1, in random order.

  • Sets the seed of the random number generator; must be an integer between 0 (inclusive) and modulus (exclusive).

    Parameters

    • seed: number

      the seed to start the random number generator with

    Returns void

    Throws

    if seed is not an integer between 0 (inclusive) and modulus (exclusive).

Generated using TypeDoc