Switch PRNG from BSD random() to Mersenne Twister
authorMarkus Armbruster <armbru@pond.sub.org>
Sat, 25 Aug 2012 15:21:10 +0000 (17:21 +0200)
committerMarkus Armbruster <armbru@pond.sub.org>
Wed, 8 May 2013 04:55:21 +0000 (06:55 +0200)
commit39c26f4238f26671537659450038e12fc35a528c
tree08a0eb658339e7daf3bab0e1a7291886c4e32ce9
parentb5d8806eb1b08d7c99fdd376cc6cd69f8c002e71
Switch PRNG from BSD random() to Mersenne Twister

random() may yield different pseudo-random number sequences for the
same seed on another system.  For instance, at least some versions of
MinGW provide a random() in -liberty that differs from traditional BSD
(see commit c8231b12).  Rather inconvenient for regression testing.

MT19937 Mersenne Twister is a proven, high-quality PRNG.  Actual code
is reference code provided by the inventors[*].  Quick tests show
performance comparable to random().

Like random(), MT is not cryptographically secure: observing enough of
its output permits guessing its state, and thus its future output.  I
don't think players can do that.

Drop the copy of BSD random() we added for Windows.

Like the previous commit, this changes the server's die rolls, and
makes fairland create a different random map for the same seed.  Update
expected smoke test results accordingly.

[*] mt19937ar.sep.tgz downloaded from
http://www.math.sci.hiroshima-u.ac.jp/~m-mat/MT/MT2002/emt19937ar.html
16 files changed:
src/lib/gen/chance.c
src/lib/gen/mt19937ar.c [new file with mode: 0644]
src/lib/gen/mt19937ar.h [new file with mode: 0644]
src/lib/subs/journal.c
src/lib/w32/random.c [deleted file]
src/lib/w32/random.h [deleted file]
src/lib/w32/random_r.c [deleted file]
src/lib/w32/w32misc.h
tests/fairland-test
tests/fairland/fairland.out
tests/fairland/fairland.xdump
tests/fairland/newcap_script
tests/smoke-test
tests/smoke/journal.log
tests/smoke/smoke.out
tests/smoke/smoke.xdump