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)

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!?

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...

Victor
-- 
Victor Stinner aka haypo
http://www.haypocalc.com/blog/

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

Répondre à