Logo

Programming-Idioms

History of Idiom 70 > diff from v23 to v24

Edit summary for version 24 by Nepta:
[Lua] forgot to expllain stuff

Version 23

2016-11-05, 02:59:19

Version 24

2016-11-05, 03:00:47

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() )
Code
math.randomseed( os.time() )
Comments bubble
os.time is precise
Comments bubble
os.time is accurate to a second only
Doc URL
http://www.lua.org/manual/5.3/manual.html#pdf-os.time
Doc URL
http://www.lua.org/manual/5.3/manual.html#pdf-os.time
Demo URL
http://codepad.org/edxMmZwY
Demo URL
http://codepad.org/edxMmZwY