LUA math.random algorithm

Posts 1–3 of 3 · Page 1 of 1
LUA math.random algorithm
Currently, I'm working on a way to predict Nutscript and Clockwork's rolling system so that people can get perfect rolls each go, however one thing I haven't been able to find is the source code for math.random in Lua, if I'm correct the default randomseed is os.time(). If anyone could drop it for me, you'd be doin' me a massive favour.
I'm also going to ask, what is the default seed Lua uses?
https://github.com/LuaDist/lua/blob/...ib.c#L181-L206

It is dependent on the C++ compiler used.
The lua manual:
This function is an interface to the simple pseudo-random generator function rand provided by ANSI C. (No guarantees can be given for its statistical properties.)
Edit: I have heard that the default seed is 1 but I can't find any official source so it might depend on implementation aswell.

Edit 2: https://linux.die.net/man/3/rand
If no seed value is provided, the rand() function is automatically seeded with a value of 1.
Posts 1–3 of 3 · Page 1 of 1

Post a Reply

Similar Threads

Talk with us