Random
Functions
getRandom
▸ getRandom(seedOrRNG
): float
Returns a random float between 0 and 1. It is inclusive on the low end, but exclusive on the high
end. (This is because the RNG.RandomFloat
method will never return a value of exactly 1.)
If you want to generate an unseeded number, you must explicitly pass undefined
to the
seedOrRNG
parameter.
Parameters
Name | Type | Description |
---|---|---|
seedOrRNG | undefined | RNG | Seed | The Seed or RNG object to use. If an RNG object is provided, the RNG.Next method will be called. If undefined is provided, it will default to a random seed. |
Returns
float
Defined in
packages/isaacscript-common/src/functions/random.ts:15
getRandomFloat
▸ getRandomFloat(min
, max
, seedOrRNG
): float
Returns a random float between min and max.
For example:
const realNumberBetweenOneAndThree = getRandomFloat(1, 3, undefined);
If you want to generate an unseeded number, you must explicitly pass undefined
to the
seedOrRNG
parameter.
Parameters
Name | Type | Description |
---|---|---|
min | int | The lower bound for the random number (inclusive). |
max | int | The upper bound for the random number (exclusive). |
seedOrRNG | undefined | RNG | Seed | The Seed or RNG object to use. If an RNG object is provided, the RNG.Next method will be called. If undefined is provided, it will default to a random seed. |
Returns
float
Defined in
packages/isaacscript-common/src/functions/random.ts:38
getRandomInt
▸ getRandomInt(min
, max
, seedOrRNG
, exceptions?
): int
Returns a random integer between min and max. It is inclusive on both ends.
For example:
const oneTwoOrThree = getRandomInt(1, 3);
If you want to generate an unseeded number, you must explicitly pass undefined
to the
seedOrRNG
parameter.
Parameters
Name | Type | Default value | Description |
---|---|---|---|
min | int | undefined | The lower bound for the random number (inclusive). |
max | int | undefined | The upper bound for the random number (inclusive). |
seedOrRNG | undefined | RNG | Seed | undefined | The Seed or RNG object to use. If an RNG object is provided, the RNG.Next method will be called. If undefined is provided, it will default to a random seed. |
exceptions | readonly int [] | [] | Optional. An array of elements that will be skipped over when getting the random integer. For example, a min of 1, a max of 4, and an exceptions array of [2] would cause the function to return either 1, 3, or 4. Default is an empty array. |
Returns
int