--Linear Congruential Generatorfunction lcg(s, r)local temp ={}function temp:random(a, b)local y = mod(self.a * self.x + self.c, self.m)
self.x = y
ifnot a thenreturn y /65536elseifnot b thenif a ==0thenreturn y
elsereturn1+ mod(y, a)endelsereturn a + mod(y, b - a +1)endendfunction temp:randomseed(s)ifnot s then
s = seed()end
self.x = mod(s,2147483648)endif r then--from Numerical Recipesif r =='nr'then
temp.a =1664525
temp.c =1013904223
temp.m =65536--from MVCelseif r =='mvc'then
temp.a =214013
temp.c =2531011
temp.m =65536end--from Ansi Celse
temp.a =1103515245
temp.c =12345
temp.m =65536end
temp:randomseed(s)return temp
end
print("wutwut =".. lcg(0):random())
print("wutwut =".. lcg(0):random())
print("wutwut =".. lcg(0):random())
However, the output is always the same number. What am I doing wrong?