Re: PRNG for Lua 4.0?
[
Date Prev][
Date Next][
Thread Prev][
Thread Next]
[
Date Index]
[
Thread Index]
- Subject: Re: PRNG for Lua 4.0?
- From: Geoff Leyland <geoff_leyland@...>
- Date: 2013年9月10日 12:24:17 +1200
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)