I know that you can set the seed of lua's random number generator with math.randomseed().
I want to generate two separate deterministic sequences of numbers somewhat in parallel. I have reduced my problem to something to the effect of this:
-- assume seed1 and seed2 exist and are positive integers.
local sequence1 = {};
local sequence2 = {};
math.randomseed(seed1);
for i = 1,50 do
sequence1[#sequence1 + 1] = math.random();
end
seed1 = math.getseed(); -- This is the function that I want.
-- stuff
math.randomseed(seed2);
for i = 1,75 do
sequence2[#sequence2 + 1] = math.random();
end
seed2 = math.getseed(); -- This is the function that I want.
-- stuff
math.randomseed(seed1);
for i = 1,50 do
sequence1[#sequence1 + 1] = math.random();
end
seed1 = math.getseed(); -- This is the function that I want.
I have looked through the documentation and thrown the math table into a k,v in pairs for loop and nothing has come up. Does any such function exist in lua, or must I write my own generator for this purpose?
Aucun commentaire:
Enregistrer un commentaire