Random

Show Deprecated

The Random data type generates pseudorandom numbers and directions.

Summary

Constructors

new(seed: number)  

Methods

NextInteger(min: number, max: number): number  

Returns a pseudorandom integer uniformly distributed over [min, max].


Returns a pseudorandom number uniformly distributed over [0, 1).

NextNumber(min: number, max: number): number  

Returns a pseudorandom number uniformly distributed over [min, max).


Returns a unit vector with a pseudorandom direction.

Clone(): Random  

Returns a new Random object with the same state as the original.

Constructors

new

Parameters

seed: number

Code Samples

Datatype.Random

local max = 2147483647 -- use a large integer
local seed = math.random(max)
local generator = Random.new(seed)

Methods

NextInteger

Returns a pseudorandom integer uniformly distributed over [min, max].

Parameters

min: number
max: number

Returns

NextNumber

Returns a pseudorandom number uniformly distributed over [0, 1).

Returns

NextNumber

Returns a pseudorandom number uniformly distributed over [min, max).

Parameters

min: number
max: number

Returns

NextUnitVector

Returns a unit vector with a pseudorandom direction. Vectors returned from this function are uniformly distributed over the unit sphere.

Returns

A unit vector with a pseudorandom direction.

Clone

Returns a new Random object with the same state as the original.

Returns