math.randomseed()

Type Function
Library math.*
Return value None
Revision 2014.2407
Keywords randomseed
See also math.random()

Overview

Sets x as the "seed" for the pseudo-random generator: equal seeds produce equal sequences of numbers.

Syntax

math.randomseed( x )
x (required)

Number. A number.

Examples

math.randomseed(1234)
print (math.random(), math.random(), math.random())  ----> 0.31763056866714     0.416967588671  0.97426279353642
math.randomseed(1234)
print (math.random(), math.random(), math.random())  ----> 0.31763056866714     0.416967588671  0.97426279353642

math.randomseed( os.time() )  ----> a different sequence each time if there is a long enough time between invocations