Complete.Org: Mailing Lists: Archives: freeciv-dev: June 2000:
[Freeciv-Dev] Re: MORT
Home

[Freeciv-Dev] Re: MORT

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: Thue Janus Kristensen <thue@xxxxxxx>, Freeciv dev list <freeciv-dev@xxxxxxxxxxx>
Subject: [Freeciv-Dev] Re: MORT
From: Andrew McGuinness <cogers@xxxxxxxxx>
Date: Wed, 7 Jun 2000 08:40:03 -0700 (PDT)

--- Thue Janus Kristensen <thue@xxxxxxx> wrote:
> On Wed, 07 Jun 2000, Robert Rendell wrote:

> > 
> > It's a constant factor used by the amortize
> function (in server/settlers.c)
> > and on values passed to that function.  Reading
> through amortize(), I've
> > finally deciphered what it does (on the 10th
> attempt)...
> > 
> > amortize(b, d) returns b * ((MORT - 1)/MORT)^d
> > 
> > (^ = to the power of)
> > 
> > Plus, it has tests to prevent the numbers getting
> too big.  It takes
> > advantage of the fact that (23/24)^12
> approximately = 3/5 to chug through d
> > in chunks of 12, and then does the remaining
> multiplications of (23/24).
> > 
> > Having worked this out, I think a comment to that
> effect above the amortize
> > function might save others the joy of trying to
> decipher this function (my
> > brain hurts).
> > 
> > Now, the question remains: WHY do you want to
> scale values by (23/24)^d?
> > How does that help the AI in scoring various
> choices?
> 
> Well, you still haven't explained what MORT really
> is...
> And what does the amortize function calculate
> anyway? I mean WHY does it
> calculate what it does?
> *Thue is too lazy to try to figure out himself*
> 
> btw, I think we all agree that that code is
> absolutely horrible...
> 
> -Thue

It obviously is a way of providing a bit of
short-termism to the AI (the benefit of having an
improvement in N turns is 23/24 as much as it would be
to  have it in N-1 turns).  Where the "magic"  number
of 24 comes from I couldn't say - it is part of the
AI's fundamental "economics".  It would be an ideal
parameter for tuning by experiment, as discussed
recently.

Whether or not the code is absolutely horrible, I
suspect it pre-dates the widespread availability of
FPU hardware.  I really doubt that the code saves any
time over 

const double MORTD=(double)(MORT-1)/MORT;
return (int)((double)b*exp(MORTD,d));

on any machine with a FPU

And if you were really desperate to optimise, you'd
use a lookup table and interpolate anyway...

--
Andrew McGuinness 


=====
Andrew McGuinness                Luton, UK
andrew_mcguinness@xxxxxxxxxxx

__________________________________________________
Do You Yahoo!?
Yahoo! Photos -- now, 100 FREE prints!
http://photos.yahoo.com



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