Commit graph

9 commits

Author SHA1 Message Date
f18159fb23 tests/fairland: Improve coverage
Rename the existing fairland run to "plain".

New run "stunted" to cover larger minimal distances, islands
that can't fully grow, and islands that can't be placed.

New run "no-spike" to cover 0% spike.

New run "spike" to cover high spike percentage, mountains and -i.

Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
2021-01-05 10:41:35 +01:00
c4441014e3 fairland: Show a more useful map
The map fairland shows has absolute 0,0 in the top-left corner, while
POGO's map * has it in the center.  Shift fairland's map to match
POGO's.

The map shows sea as '.', island sectors as '%', capitals as '#',
mountains as '^', and other continental sectors as a letter or digit
that encodes the continent number modulo 62.  When a continent has no
"other" sectors, its continent number is not shown.  Remove this
pathological case by using letter/digit for capitals, and '#' for
other continental sectors.

Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
2021-01-05 10:41:35 +01:00
fed6620a0b tests/files tests/fairland: Check stderr and exit status
New helper run_and_cmp to automate the job: run a program capturing
its standard output, standard error and exit status, then compare the
actual with the expected results.

Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
2015-02-01 16:52:59 +01:00
37ff3774ec tests: Normalize trailing white space away in test output
We don't really care for it there, and git's pre-commit hook flags it,
which is annoying.

Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
2014-01-06 20:49:59 +01:00
c798863bd7 Change fairland island size probability distribution
Island size is randomly chosen from the interval [1..2*is+1], with
expected value is.  Use two dice to roll the size instead of one.
This makes extreme sizes much less likely.
2013-05-08 06:57:55 +02:00
1bbbd5e27f Remove a blank line before "fairland rips open"
One blank line before and after now, looks better.
2013-05-08 06:55:21 +02:00
39c26f4238 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
2013-05-08 06:55:21 +02:00
b5d8806eb1 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.
2013-05-08 06:55:20 +02:00
ed8eead0ba Add fairland test to make check 2013-05-08 06:55:18 +02:00