Fix tiny error in distribution of die rolls

"random() % n" is sound only when n is a power of two.  The error is
hardly relevant in Empire, because random() yields 31 bits, and our n
are always much smaller than 2^31.  Fix it anyway.

Use smallest the 2^m >= n instead of n, and discard numbers exceeding
n.

Bonus: faster for me even in the worst case n = 2^m+1.

Like the recent change to damage(), this changes some of the server's
die rolls, only this time the effect is pretty pervasive.  Worse,
fairland now creates a completely different random map for the same
seed.  Update expected smoke test results accordingly.
This commit is contained in:
Markus Armbruster 2012-08-19 12:19:04 +02:00
parent 54ddcd0f5a
commit b5d8806eb1
6 changed files with 3477 additions and 3456 deletions

View file

@ -17,44 +17,44 @@ World dimensions: 64x32
seed is 1
placing capitals...
growing continents...
growing islands: 1(29) 2(1) 3(5) 4(3) 5(12) 6(7) 7(16) 8(7) 9(6) 10(16)
growing islands: 1(22) 2(21) 3(16) 4(18) 5(25) 6(18) 7(10) 8(17) 9(19) 10(21)
elevating land...
designating sectors...
adding resources...
setting coastal flags...
writing to sectors file...
f f f f . % % . . . g g # # g g . . . . . . . . d d d d d . . .
f . . f . % % . . g g g g g g g . . . . . . . d # # d d d d . .
. . . . . % % % % . g g g g g . . . . . . . . . d d d d d . . .
. . . % % % % % % . g g g . . . . . . . . . . . d d d . . . . .
. . . . % % % % . % . . g . . . . e e e . . . . d . . . . . . .
. . . . . % % . . . . . . . . . . e . e . . . . . . . . . . . .
c . . . % % % % . . . . . . . . e e e e e . . . . . . . . . . c
c . . . . . . % . . . . . . . e e e e e e . . . . . . c c . . .
c . . . . b b . . b . . . . . . . # # e e e . . . . . . c c c c
c . . . b b . b b b b b . . . . e e e e e . . . % % . . . c c c
c c . . . b b b # # b . . . . . . . e e e . . . % % . . . c # #
c . . . b b b b b b . . . . % . . . . e . . . . % . . . . c c c
c c . . . . b b b b . . . % % % . . . . . . . . . . . . . . c c
c c . . . . b b b b . % % % % % . . . . . . . . . . % % . . . c
. . . . . . . . . . . . . % % . . . . . . . % % . . % % % . % .
. . . . . . . . . . . . . % . . . . . . % % % % . . % % . % % .
. . . a . . . . . . . . . . . . . . . . . . . % . . . . . % % %
a a a a a a . . h h . h . . . . % % % % % . . . . . . . . . . .
. . a a a a . . h h h h h . . . . % % % % . . . . . . . . . % %
. a # # a . . . . h h h h h h . % % % % . . . . . . j j j . % %
% . a a a a a . . . h h h h h h . % % % . . j j j j j j . . % %
. a a a a a a a . . h # # h h h . . . . . . j j j j j . . % % %
% . a a . a . . . . h h h h . . . . . . i . . . j j # # . . . %
% . . . . . . . . . . . . . . . . . . i . . . . j j j j . . % %
% . . . . . . . . . . . . . . . . . i i . . i . . j j j j . . .
. f . . . . . % . . % . . . . . . . i i i i . . . j j j j . . .
. . f . . . . . . . % % . . . . . . i # # i i . . . . . . . . .
. f f . . . . . . . . . . . . . . . i i i i i i . . . . . . . .
f f f f . . . . . . . . . . . . . . . i i i i i . . d . . . . .
f f f f . . . . . . . . . . . . . . . . . i i . . d . . . . . f
f # # f f . % . . . . . g g g . . . . . . i i . . d d d . . . f
f f f f . % % . . g g g g g . . . . . . . i . . d d d d . . . f
. . . 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 . . . . . .
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 5,19
newcap 1 57,5
add 2 2 2 p
newcap 2 16,10
newcap 2 22,26
add 3 3 3 p
newcap 3 60,10
newcap 3 54,26
add 4 4 4 p
newcap 4 49,1
newcap 4 52,16
add 5 5 5 p
newcap 5 34,8
newcap 5 37,31
add 6 6 6 p
newcap 6 2,30
newcap 6 6,20
add 7 7 7 p
newcap 7 24,0
newcap 7 21,5
add 8 8 8 p
newcap 8 23,21
newcap 8 6,30
add 9 9 9 p
newcap 9 38,26
newcap 9 36,20
add 10 10 10 p
newcap 10 52,22
newcap 10 36,10
add 11 visitor visitor v