Complete.Org: Mailing Lists: Archives: freeciv-dev: April 2002:
[Freeciv-Dev] server/settlers.c cleanup 2
Home

[Freeciv-Dev] server/settlers.c cleanup 2

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: <freeciv-dev@xxxxxxxxxxx>
Subject: [Freeciv-Dev] server/settlers.c cleanup 2
From: <per@xxxxxxxxxxx>
Date: Sat, 13 Apr 2002 18:16:06 +0200 (MEST)

This cleanup introduces slight behaviour changes (cumulative, though, so
autogames get totally different). This is due to the reformulation of
amortize taken from an old patch I found lying around in the archives.

The new amortize is not _exactly_ identical to the old. I ran it through
two for loops from 0 to 999 to test all possible want values and a more
than reasonable range of possible delays (what would last > 999 turns?).

The result: 907159 calls produce the same result, 90842 are different;
of those, 415 are more than 1 off, none are more than 2 off.

Sum of all results, old amortize: 1087167885
Sum of all results, new amortize: 1087077186

I'd say that is an acceptable approximation to the behaviour of the old
amortize.

I timed the tests, and old amortize performed as follows:
real    0m0.770s
user    0m0.740s
sys     0m0.000s

The new amortize as follows:
real    0m0.549s
user    0m0.550s
sys     0m0.000s

Strange, huh? Lesson: It is difficult to outsmart a good compiler and a
modern CPU with performance hacks.

This new amortize should easier to understand, and allows MORT to have
other values than 24. I intend to write a patch to take advantage of this
when/if this patch reaches the safe shores of cvs.

(We can even start to experiment a little with pitfight games where we
have different MORT for different players, to see if 24 really is as
optimal as Syela thought.  Though I know that 24 is hardcoded in several
places still.)

BTW, new amortize with dynamic MORT performs as follows:
real    0m0.602s
user    0m0.600s
sys     0m0.000s

Yours,
Per

"Treason doth never prosper: what's the reason?
Why, if it prosper, none dare call it treason."
 -- Sir John Harrington (1561-1612)

Attachment: settlerscleanup2.patch
Description: Text document


[Prev in Thread] Current Thread [Next in Thread]