Open Source Cross-Platform Game Programming

Random

Library for generating random numbers. Generally uses the default-seeded random number generator from the underlying platform. For seedable random numbers that generates the same numbers per seed regardless of export platform, use the SRandom library.

function randomBool()[link]

Generates a random boolean.

Return Value

TypeDescription
boolean

A random boolean

function randomFloat()[link]

Generates a random floating point decimal number from 0 up to (but not including) 1.

function randomInt(minInclOrMax, optionalMax)[link]

Generates a random integer within the given range. There are two ways randomInt can be called. When called with one parameter, it will generate a random number from 0 up to the number you provide (exclusive) i.e. if you call randomInt(10), you will get numbers from 0 through 9, but not 10 itself. When called with two parameters, it will generate a random number from the first number (inclusive) to the second number (exclusive) i.e. if you call randomInt(5, 10), you will get numbers from 5 through 9, but not 10 itself (but it may be 5).

Arguments

NameTypeOptionalDescription
minInclOrMax integer

Minimum number that randomInt will return.

optionalMax integer Optional

Maximum number that randomInt will return.

Return Value

TypeDescription
integer

A random integer