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
This commit is contained in:
Markus Armbruster 2012-08-25 17:21:10 +02:00
parent b5d8806eb1
commit 39c26f4238
16 changed files with 3799 additions and 4356 deletions

View file

@ -17,44 +17,44 @@ World dimensions: 64x32
seed is 1
placing capitals...
growing continents...
growing islands: 1(22) 2(21) 3(16) 4(18) 5(25) 6(18) 7(10) 8(17) 9(19) 10(21)
growing islands: 1(22) 2(25) 3(21) 4(15) 5(21) 6(13) 7(29) 8(15) 9(12) 10(15)
elevating land...
designating sectors...
adding resources...
setting coastal flags...
writing to sectors file...
. . . h h h h . . . . . . . . . . e e e e e e . % . . . a . . .
. . . h h h h . . . g g . % % % . e e e . e . % . . . a . a . .
. . . . h . h . . g g g g . % % % . . e . . . % % . . a a a . .
. . . . . . . % . g g g g . . % % % . . % % % % % . . a a a . a
a . . . . % % % . g g g g g g . % % % . % % % % % % . a a a a a
. . . . % % % . g g # # g g . % % % % . . % % % % . . a # # a .
. . . . % % % % . g g g g g g . % % . . j . % % % . . a a a a a
. . % . % % % % . . . g g . . % . . j j j . . . . . . . a a a .
. % % . . % % % % % . . . . . . . j j j j . . . . . % % . . a a
% % . . % % % . . . . % . . j j j j j j j . . . . . % . . . . .
% % % . % % . . . . % % % % . . j j # # j j . . % % % . . . % %
% % . . . . . % % . . % % . . . . j j j j . . % % % % . . . % %
% % . . . . % % % % . % % . . . j j j j j . % % % % % . . . . %
% . . . . . % % % % . % . . . . . . . . . % % % . . . d . . . .
. . . . . . % % % % % . . . . . . . . . . . . . . d d d d d . .
. % . . . . % % . . . . . . . . . i i i . . . d d d d d d . % %
% % . . . f . . . . . . . . . . i i i i . . . . d d # # d d . %
% % . f f f f . . . . . % . . . i i i i . . . . . d d d d . % %
% % . f f f f f . % % % % . % % . . i i i . . . . d d d d d . %
% . f f f f f . % % % % . % % % . i i i i . . . . . . d d . % %
% . f # # f f . % % % % . % % % . i # # i i . . . . . . d . . %
. f f f f f f . % % % % . % % % . i i i i . . . . . . . . . % %
. . . f f f . . . % % % . % % % % . i . . . . . . . . . . . . %
. . . . f . . . % . . . . . . . % . i . . . . . . . . . . . . .
. . . . . . . . . . b b b b b . . . i . . . . . . . . c c c . .
. . . . . . . . . b b b b b b . . . . . . . . . . c c c c . . .
. . . . . . . . . b b # # b b b . . . . . . . . c c c # # c c .
. . h . . . . . . b b b b b . . . . . e e . . . c c c c c . . .
. h h h h . . . . . b b b . . . . . . e e e . . . c c c c c . .
. h h h h . . . . b b b b . . . . . e e e . . . . c c c c . . .
. . h # # h h h . . . . . . . . e e e e e e . . . . c . . . . .
. . h h h h h . . . . . . . . . . e # # e e . . . c . . . . . .
. e e e e e . . % % % % . # # i i . . . . . . . % . % . . % % %
. e e e . e . % % % % . i i i i . . . . . . . . % % % . . % % %
% . . . . . . . % % % . i i i i . . g g g . . . % % % % % . % %
% . % % % % . % . . % . i i i . . g g g g . . . % % % % . . . .
. . % % % % . % . . . . . i i . . g g g g g g . . % . . . . . .
. . % % % . . . . . . . i i . . g g g # # g g . . . . . . . b .
b . % . . . a . . a a . . . . . . g g g g g . . . . . . . . b b
b . . % . a a a a a . . . . . % . g g g g . . % % . . b b b b b
b b . % . a a # # . . . . . . % % . . . . g . . % % . b b # # b
b . % . a a a a a a . . . % % % % % % % . . % . % . b b b b b b
. . % % . . a a a a a a . . . % % % % % % % % . % % . b b b b .
. . % % . a a a a a a . . . . . . % % % % . . % % % . . b b . .
. % % % % . . . . . . . . % . % . % % . . . d . % % % % . . . .
% % % % % % % % % % . . % % % % . . . . . . d . . . % . . . . .
% % . . % % % % % . . % % % % % . . . . . d . d d d . . . . . .
. . j . . . . . . . . % % % % . . . . . d d d d d . . . . . . %
. j j j j j j . . . . . % % % % . . . . d d d # # d . . . . . .
j j j j j j . . . . . . . . . % . . . . d d d d d d . . . . . .
j j j # # j j j . . . . . . . . % . . . . d d d d d . . h h . .
j j j j j . . . . . f f . . . . . . . . . d . . d . . . h h . .
. j j j j . % % . . . f f f f f . . . . . . . . . . . . . h h .
. . . . . % % . f f f f f f f . . . . . . . . . . . . . . h h .
. . . . % % % % . . f f f f . . . . . c c . . . . . . . . h h h
h h h . % % % % . f f # # f . . . . . c c c c . . . . . # # h h
h . . . . . . . % . f f f f f . . . . . c c c . . . . . . h h h
. . . . . . . % % . . . . f f . . . c # # c . . . . % . h h h h
h . . . . . . . . . . . . . . . . . c c c c c c . . % % . h h h
. . . . e e . . . . . . . . . . . . c c c c c . . % % % . . . .
. . . e e e e . . . . . . . . . . . . c c c c . % % % % % % . .
. . e # # e . . % % . . . . i . . . . . c c . % % % % % % . . .
. . e e e e e . % % . . i i i i i . . . . . . . . % % % % . % .
e e e e e e . . % % % . i i i i i . . . . . . . . . . . . % % .
A script for adding all the countries can be found in "sandbox/newcap_script".

File diff suppressed because it is too large Load diff

View file

@ -1,21 +1,21 @@
add 1 1 1 p
newcap 1 57,5
newcap 1 14,8
add 2 2 2 p
newcap 2 22,26
newcap 2 58,8
add 3 3 3 p
newcap 3 54,26
newcap 3 39,25
add 4 4 4 p
newcap 4 52,16
newcap 4 46,16
add 5 5 5 p
newcap 5 37,31
newcap 5 7,29
add 6 6 6 p
newcap 6 6,20
newcap 6 23,23
add 7 7 7 p
newcap 7 21,5
newcap 7 39,5
add 8 8 8 p
newcap 8 6,30
newcap 8 57,23
add 9 9 9 p
newcap 9 36,20
newcap 9 26,0
add 10 10 10 p
newcap 10 36,10
newcap 10 6,18
add 11 visitor visitor v