samedi 20 février 2016

Is there a good way to generate random data in Lua with no repeats?

I wrote some code for a program down below:

a = math.random(0, 9) - 0
b = math.random(0, 9) - 1
c = math.random(0, 9) - 2
d = math.random(0, 9) - 3
e = math.random(0, 9) - 4
f = math.random(0, 9) - 5
g = math.random(0, 9) - 6
h = math.random(0, 9) - 7
i = math.random(0, 9) - 8
j = math.random(0, 9) - 9

I was hoping on making it no repeats, for example the number generated with math.random in "a" will never be the name as "b-j". Also, is there a BETTER way to generate random data, as the math.random function seems to make the same numbers over and over again.




Aucun commentaire:

Enregistrer un commentaire