Complete.Org: Mailing Lists: Archives: freeciv-dev: October 2001:
[Freeciv-Dev] Re: [patch] amortize
Home

[Freeciv-Dev] Re: [patch] amortize

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: Chris Guest <chris.guest@xxxxxxxxxxxx>
Cc: "freeciv-dev@xxxxxxxxxxx" <freeciv-dev@xxxxxxxxxxx>
Subject: [Freeciv-Dev] Re: [patch] amortize
From: Raimar Falke <hawk@xxxxxxxxxxxxxxxxxxxxxxx>
Date: Thu, 25 Oct 2001 10:40:39 +0200
Reply-to: rf13@xxxxxxxxxxxxxxxxxxxxxx

On Thu, Oct 25, 2001 at 02:27:36PM +1000, Chris Guest wrote:
> I have two patches here for that rewrite the amortize function, to
> avoid the (23/24)^12 = 3/5 kludge. Patches are against
> freeciv-cvs-Oct-21 .
> 
> (1) amortize_math_patch simply reimpliments the amortize function
> using pow from <math.h> .
> 
> (2) amortize_array_patch:
> generate_amort() pregenerates an array of floats (amortize_frac) of
> the form ((MORT-1)/MORT)^n . 
> The amortize function returns (amortize_frac[delay] * benefit).
> The highest precalculated value of n, MAX_DELAY, and a highest value
> for which we can assume amortize(x, MAX_DELAY) = 0 (MAX_BENEFIT) have
> been implemented as #defines. 
> 
> I have tested both extensively and they perform more accurately than
> the current amortize (chiefly because of the kludge).
> 
> I compared their performance by averaging the log values for
> 'End/start-turn server/ai activities:' over a segment of game play
> involving 30 ai characters. I tested on a PII 300 with Linux kernel
> 2.4.2.
> 
> Original amortize:                                     0.629 seconds
> amortize using math.h pow():                           0.687 seconds
> amortize with array:                                   0.692 seconds
> 
> As this is motivated by kludge removal, I think a 9-10% ai slowdown is
> not such a big sacrifice to make, but I'd appreciate anyone trying
> these patches to give some performance indicators on other hardware.

(23/24)^12 = 0.600066154091
3/5        = 0.6

0.6/0.600066154091 = 0.0001102

This is a difference of 0.01%. This is a very small difference. So
IMHO the original kludge is quite accurate. The big question is now:
do you have noticed any difference in the AI runs which are caused by
this more accurate method?

        Raimar

-- 
 email: rf13@xxxxxxxxxxxxxxxxx
 "Understanding is a three-edged sword; 
  your side, their side, and the truth."
    -- a well-known Vorlon



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