Logo

Programming-Idioms

History of Idiom 70 > diff from v22 to v23

Edit summary for version 23 by Nepta:
New Lua implementation by user [Nepta]

Version 22

2016-02-22, 15:29:11

Version 23

2016-11-05, 02:59:19

Idiom #70 Use clock as random generator seed

Get the current date and provide it as a seed to a random generator. The generator sequence will be different at each run.

Idiom #70 Use clock as random generator seed

Get the current date and provide it as a seed to a random generator. The generator sequence will be different at each run.

Code
math.randomseed( os.time() )
Comments bubble
os.time is precise
Doc URL
http://www.lua.org/manual/5.3/manual.html#pdf-os.time
Demo URL
http://codepad.org/edxMmZwY