lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


On 10/09/2013, at 12:17 PM, Michael Horvath <mikh2161@gmail.com> wrote:

> I found this set of pseudo random number generators here:
> ...
> 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?

You're creating a new generator on each line.  Try (untested):

local R = lcg(0)
print("wutwut =" .. R:random())
print("wutwut =" .. R:random())
print("wutwut =" .. R:random())

(Also, please don't send HTML email, the list prefers plain text)