Hi,

Victor Stinner a écrit :
> Hi,
>
> I see that Wormux 0.8 uses the "ANSI C" pseudo-random number generator (PRNG):
>   modulo=32768
>   mutiplicative=1103515245
>   additive=12345
>   period=??? (maybe 32768)
>   RAND_MAX=32767
>
> It would be better to use Park-Miller PRNG (also known as "Lehmner PRNG" 
> or "Minimum standard PRNG"):
>   modulo=2147483647
>   mutiplicative=16807
>   additive=0
>   period=2147483646
>   RAND_MAX=??? (maybe 2147483646)
>   

why not ? ;)

> Current generator generates ~15 bits of entropy (in higher bits) at 
> each "clock tick" whereas Park-Miller one does generator ~31 bits. The period 
> is also better: 32768 vs 2147483646.
>
> The period is the number of clock ticks before you get the same number. Eg: 
> (n+1) % 10 has as period of 10: it generates 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 
> 1, 2, 3, (...) ;-)
>
> I checked Wormux PRNG because I saw two bonus boxes placed at the same 
> position in the same game!?
>   

it's true that it can happear many times but don't forget it take the 
ground into account and the character position. Without wind, a bonus 
box should never fall in water or on a character. So, on some maps, it's 
really difficult to find a place.

> If you choose to change the PRNG, it will break network version 
> compatibility. 
> You have to increment network protocol version. But it should be possible to 
> write a compatibility mode: if any client uses the old protocol, fallback to 
> the old PRNG. Problem: if you want to keep backward compatibility, Wormux 
> source code base will be bigger and bigger...
>   

Well, we have to increment "game version", not network protocol version. 
We have already spoken about such changes with Kurosu. It's impossible 
to keep backward compatibility for network game.

So, my idea is to update version for current svn to 0.8.1-svn both in 
autotools script (configure.ac) and in cmake one. Next release 0.8.1 
will use this random number generator.
> Victor
>   

Matt (gentildemon)


_______________________________________________
Wormux-dev mailing list
Wormux-dev@gna.org
https://mail.gna.org/listinfo/wormux-dev

Répondre à