![]() |
VOOZH | about |
This module generates a pseudo-random number. It is used the same as math.random, however it first sets up a seed so that the number is actually random.
localp={} localseeded localrandomseed=math.randomseed localrandom=math.random functionp.random(m,n) ifnotseededthen p.seed() end returnrandom(nandmormand1or0,normor1) end functionp.seed(seed) randomseed(seedor(os.time()+os.clock()*1000000000)) -- First few values of seed is not guaranteed to be random on some platforms random() random() seeded=true end functionp.main(frame) localm=tonumber(frame.args[1]) localn=tonumber(frame.args[2]) returntostring(p.random(nandmormand1or0,normor1)) end returnp