lua-users home
lua-l archive

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


On Windows XP with Lua 5.1.3, I get precisely the same values as in
Christopher's original message.

On 16 March 2010 18:10, KHMan <keinhong@gmail.com> wrote:
> Javier Guerra Giraldez wrote:
>>
>> On Tue, Mar 16, 2010 at 11:17 AM, Christopher Eykamp wrote:
>>>
>>> I'm running on Windows, embedded in a C++ app.  The chances of a re-seed
>>> seem minimal, as the two lines I posted are executed one after the other
>>> in
>>> the same file.
>>>
>>> I have temporarily resolved my problem by overwriting the random function
>>> to
>>> call my C++ program and use it's random function, which seems to be...
>>> well... random.
>>>
>>> If the seeds were the same, I would expect the results I see, but they're
>>> clearly different.
>>
>> i've just tried this:
>>
>> function tr(seed)
>>  math.randomseed( seed )
>>  print ("Seed: "..seed,
>>
>> math.random(10000),math.random(10000),math.random(10000),math.random(10000))
>> end
>>
>> for _,s in ipairs
>> ({3063121584,2428144928,3559301251,4287790062,2737803158,2458923424})
>> do
>>  tr(s)
>> end
>>
>> and i get:
>>
>> Seed: 3063121584        2331    1179    6134    7741
>> Seed: 2428144928        9074    3329    5507    8307
>> Seed: 3559301251        1739    4278    5885    8691
>> Seed: 4287790062        6352    1754    759     588
>> Seed: 2737803158        5587    8387    1486    6766
>> Seed: 2458923424        4302    7992    5852    5221
>>
>> i guess that your Lua's math.random() is not stock Lua's.  if it were,
>> we should get the same numbers given the same seeds.
>>
>> can other members try this and see if everybody gets exactly the same
>> random numbers?  this is Kubuntu 9.04 x86_64 with Lua 5.1.4 default
>> install.
>
> Got a bunch of different numbers with Lua 5.1.4 on Cygwin 1.7 and Lua 5.1.4
> on MinGW.
>
> Hard to believe it's a Lua problem...
>
> --
> Cheers,
> Kein-Hong Man (esq.)
> Kuala Lumpur, Malaysia
>