math.randomseed

Seeds the random number generator

Prototype

math.randomseed (n)

Description

Seeds the random number generator with an integer. Re-seed with the same number to regenerate the same sequences by calling math.random.

Seeding with os.time () is a common technique to make random numbers different each time. Be aware however that for cryptographic purposes, the time of day is hardly a secret.

math.randomseed (44)    -- fixed random seed
math.randomseed (os.time ())  -- randomize from whatever the time is
Also see the world.MtSrand function for seeding the Mersenne Twister random number generator.

Lua functions

Topics