|
|
Warp wrote:
> Rune <new### [at] runevisioncom> wrote:
>
>>I think that Warp just meant something along the lines that no sequence
>>generated by a computer is *really* non-predictable.
>
>
> No, what I meant was that POV-Ray uses a RNG such that you can predict
> its entire outcome from the very first value it returns, even if you don't
> know the original seed. That way it's very predictable.
>
> There exist other RNGs where this is not so. For example you can't
> deduce the outcome of the Mersenne Twister with only the first result it
> returns (you need to read several hundreds of values before you can
> predict accurately the rest). With the Blum Blum Shub RNG it's even
> more difficult.
I wrote a C++ class that generates pseudo-random numbers using an array
of 24 shorts. I extract from the positions indexed by the first eight
prime numbers (2, 3, 5, 7, 11, 13, 17 and 19), pair them up and take the
maximum value from each pair, then pair up the remaining four values and
take the minimum from each pair, add them and the values in positions 22
and 23, shift values in positions 0 through 21 to the next higher
position, put the sum into position 0 and return the low byte of the sum
as the return value. I also increment position 23 by 24109 (which is
floor(65536/e), although I suspect that any odd value would work).
To initialize I fill the shift register with the seed value, and then
generate byte values until every value from 0 to 255 has been generated
at least once.
I haven't tested to see if there is any unusual patterns from the
results, but I suppose I could go do that.
I originally wrote this to use to randomly generate game worlds, and I
wanted to make very sure that the chance of two game worlds being the
same was exceptionally small. There are 2^384 possible states for the
generator, and I'm not aware of any short loops in it.
Regards,
John
Post a reply to this message
|
|