[Freeciv-Dev] Re: server/settlers.c cleanup 3
[Top] [All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
On 16 Apr 2002, Markus Linnala wrote:
> "Ross W. Wetmore" <rwetmore@xxxxxxxxxxxx> writes:
>
> > A good way to handle weighting functions is to make all your input
> > calculations run in a fixed range, then pass the final result through
> > an array lookup where the array is pre-computed for the set of values
> > and that particular weighting function.
>
> int amortize(int benefit, int delay)
>
> I made quick test (added debug log and ran a game) and seems
> that benefit had range 0 - 11857, but only had 1596 distinct
> values. Delay had range between 0 - 396525, but effective range
> was between 0 and 234 because if delay is big amortize goes to
> 0.
Since the result is benefit * something^delay
all we need is precomputed array of 235 floats and then the code would be
int amortize(int benefit, int delay)
{
static float amort_factorp[235] =
{1, 0.99, 0.976, ....}
if (delay < 0 || delay > 234) return 0;
return (int) benefit * amort_factor[delay];
}
where I have probably commited some capital crimes by treating FP number
improperly.
This, however, does not provide the possibility of varying MORT, so I
guess it's of little use.
G.
>
> Because benefit is 10 times bigger than another benefit, value
> is also 10 times that. So we need only fixed range of 10, 100 or
> 1000 precomputed values at benefit. First scale benefit or down
> and later scale value back.
>
> Guess we need precomputed array of size about 100k
> (100*256*sizeof(int)).
>
>
> We could also check if delay is bigger than some value, return
> zero. We in the earth we need to amortize something that has
> delay over 1000? Bug somewhere maybe?
>
>
- [Freeciv-Dev] Re: server/settlers.c cleanup 3, (continued)
- [Freeciv-Dev] Re: server/settlers.c cleanup 3, Mike Kaufman, 2002/04/14
- [Freeciv-Dev] Re: server/settlers.c cleanup 3, Raimar Falke, 2002/04/14
- [Freeciv-Dev] Re: server/settlers.c cleanup 3, Ross W. Wetmore, 2002/04/14
- [Freeciv-Dev] Re: server/settlers.c cleanup 3, Per I Mathisen, 2002/04/14
- [Freeciv-Dev] Re: server/settlers.c cleanup 3, Mike Kaufman, 2002/04/14
- [Freeciv-Dev] Re: server/settlers.c cleanup 3, Raimar Falke, 2002/04/14
- [Freeciv-Dev] Re: server/settlers.c cleanup 3, Per I Mathisen, 2002/04/14
- Message not available
- [Freeciv-Dev] Re: server/settlers.c cleanup 3, Ross W. Wetmore, 2002/04/14
- [Freeciv-Dev] Re: server/settlers.c cleanup 3, Per I Mathisen, 2002/04/14
- [Freeciv-Dev] Re: server/settlers.c cleanup 3, Markus Linnala, 2002/04/16
- [Freeciv-Dev] Re: server/settlers.c cleanup 3,
Gregory Berkolaiko <=
- Message not available
- [Freeciv-Dev] Re: server/settlers.c cleanup 3, Ross W. Wetmore, 2002/04/16
- [Freeciv-Dev] Re: server/settlers.c cleanup 3, Gregory Berkolaiko, 2002/04/15
- [Freeciv-Dev] Re: server/settlers.c cleanup 3, Raahul Kumar, 2002/04/16
- [Freeciv-Dev] Re: server/settlers.c cleanup 3, Ross W. Wetmore, 2002/04/16
[Freeciv-Dev] Re: server/settlers.c cleanup 2, Gregory Berkolaiko, 2002/04/15
|
|