TruWorlds

Random

Accessed via random

The random module provides a psuedo-random number generator.

Properties

random.current_seed number read-only

The current seed of the random number generator. This seed is unique to the current script environment and is not shared across scripts. By default, the seed is initialized to a random value (see random_seed()).

Functions

random.seed(seed: number)

Sets the seed for the random number generator. The random number generator will always produce the same sequence of numbers for a given seed. If you want to produce a different sequence of numbers each time, you can use the random_seed function to set the seed to a random value.

random.random_seed()

Sets the seed for the random number generator to a random value. The seed that is generated using a combination of the current time and other system-level factors to ensure that it is unique for each script environment.

random.between(min: number, max: number) Returns number

Returns a random integer between min and max, both inclusive.

random.nbetween(min: number, max: number) Returns number

Returns a random number between min and max, both inclusive. The number's decimal component will contain random digits.

random.decimal() Returns number

Returns a random decimal number that is greater than or equal to 0 and less than 1. If not zero, the decimal component will contain random digits.