lua-users home
lua-l archive

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


On 3/19/07, Luiz Henrique de Figueiredo <lhf@tecgraf.puc-rio.br> wrote:
> Hrm, that's not been my experience. To be clear, I understand (and
> expect) that feeding it a particular random seed will produce a fixed
> sequence. I have never before experienced it where the first result
> returned isn't affected by that sequence, however.

Sorry, you're right. I misread your posting. Sorry about the noise.
And I don't know why you're getting the same first value.
--lhf

I've done a bit of digging, and I believe it may have to do with the
precision of your seed.  Take the following example:

local values = {}
for i=1,1e1 do
 math.randomseed(i)
 values[math.random(100)] = true
end
print(#values)

Some results:
1e1: 1 unique result
1e2: 2 unique results
1e3: 11 unique results
1e4: 100 unique results

I suspect that has implications overall, when trying to seed the PNG
in successive atempts, since in my experience consecutive values yield
the same result, up until some point.  Thats the best I can offer with
my limited resources at the moment.

- Jim