Complete.Org: Mailing Lists: Archives: freeciv-dev: December 2001:
[Freeciv-Dev] Re: [PATCH] advdomestic.c cleanup (PR#1149)
Home

[Freeciv-Dev] Re: [PATCH] advdomestic.c cleanup (PR#1149)

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: Petr Baudis <pasky@xxxxxxxxxxx>
Cc: Mike Kaufman <mkaufman@xxxxxxxxxxxxxx>, freeciv-dev@xxxxxxxxxxx
Subject: [Freeciv-Dev] Re: [PATCH] advdomestic.c cleanup (PR#1149)
From: Chris Richards <chrisr@xxxxxxxxxxxxxxxx>
Date: 23 Dec 2001 11:22:18 -0600

It can be further reduced to:

   cost = (amortized * weight) / (MAX(0, weight - amortized));

except that you are incurring round-off error from amortized results
in cost being 1 less (integer-wise) than with the old formula.

Not knowing how round-off was playing a part in the previous
heuristic, I can't common on which cost is better.

Cheers,
cjr

> > weight = (POLLUTION_WEIGHTING + pplayer->ai.warmth) * 64;
> Not entirely sure. Appears as some kind of combination of rescaling factor and
> yet another heuristic constant to me, but I need Ross' opinion here. I really
> have no idea why it's there, as it appears to me that:
> 
>   weight = (POLLUTION_WEIGHTING + pplayer->ai.warmth) * 64;
>   int amortized = amortize(weight, 100 / pcity->pollution);
>   cost = ((amortized * weight) / (MAX(1, weight - amortized))) / 64;
> 
> is equivalent to
> 
>   weight = (POLLUTION_WEIGHTING + pplayer->ai.warmth);
>   int amortized = amortize(weight, 100 / pcity->pollution);
>   cost = (amortized * weight * 64 * 64) / (MAX(1, (weight * 64) - (amortized 
> * 64)) * 64);
> 
> which is equivalent to
>   ...
>   cost = (amortized * weight * 64 * 64) / (MAX(1, (weight - amortized) * 64) 
> * 64);
> 
> so
> 
>   cost = (amortized * weight * 64) / (MAX(1, (weight - amortized) * 64));
> 
> thus
> 
>   cost = (amortized * weight) / (MAX(1 / 64, weight - amortized));


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