Skip to main content

Random Utilities

import { Random } from "//packages.education/agent"
// Usage: Random.getRandomBoolean();
// -- OR --
import { getRandomBoolean } from "//packages.education/agent/utils";
// Usage: getRandomBoolean();

Functions

getRandomBoolean([probability: number]): boolean

Generates a random boolean value which is true with the given probability.

Default: probability: 0.5

getRandomInteger(min: number, max: number): number

Generates a random integer number between the given values (both ends inclusive).

getRandomFloat(min: number, max: number): number

Generates a random real number between the given values (both ends inclusive).

getRandomColor(): string

Generates a random CSS color in the rgb(r, g, b) format.

getRandomHeading(): string

Generates a random heading, a number between 0 (inclusive) and 360 (exclusive).