lua-users home
lua-l archive

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


I copied what you typed but still get the bad results. Is it because I
am working in Lua 4.0 not 5.0?

I am creating a script for a video game. The game's authors decided to
change the behavior of random() so that it gets seeded differently
every time you play a match. So I need to write my own PRNG to get the
old Lua behavior.

On Mon, Sep 9, 2013 at 9:31 PM, Geoff Leyland <geoff_leyland@fastmail.fm> wrote:
> On 10/09/2013, at 1:10 PM, Michael Horvath <mikh2161@gmail.com> wrote:
>
>> I don't think it worked. I got the following output:
>>
>> wutwut =0.1883697509765625
>> wutwut =0
>> wutwut =0.1883697509765625
>
> Check what you typed.  It worked for me (after I added local mod = math.mod):
>
> lua test2.lua
> wutwut =0.18836975097656
> wutwut =0.087860107421875
> wutwut =0.15574645996094
>
> By the way, what's wrong with math.random?  The RNG you've implemented isn't a particularly good one, so why not stick with the default (which is very good in LuaJIT)