Reputation: 79
If I know that the seed of random generator is the current unix time:
math.randomseed(os.time())
could I predict what the next result of math.random
is?
I'm using math.random
(6) (numbers between 1-6)
and could I create a script that will show me what random numbers will be in like 10 seconds using this logic?
Essentially I want to know if there's a way to recreate math.random
in Lua and reverse engineer it?
Upvotes: 0
Views: 2100
Reputation: 1521
If you know the exact time at which they seed the generator (os.time()
returns second time, and it has to be EXACTLY the same), and are running Lua on the same platform, then you can simply do:
math.randomseed(time_that_you_know)
math.random(6)
and your answer will be the same as theirs; that's how pRNGs work.
Upvotes: 2