Type Function Library math.* Return value none Revision 2017.3060 Keywords randomseed See also math.random()
Sets the "seed" for the pseudo-random number generator. The same seed will produce the same sequence of random numbers each time and can be useful for testing but it is generally more desirable to have a different sequence for each run by using something like the current time as the seed (see below).
-- Produces a different sequence each time (assuming enough time between invocations) math.randomseed( os.time() )
-- Produces the same sequence of numbers 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