[Freeciv-Dev] Re: server/settlers.c cleanup 3
[Top] [All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
"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.
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?
--
//Markus
- [Freeciv-Dev] Re: server/settlers.c cleanup 3, (continued)
- [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, 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 <=
- [Freeciv-Dev] Re: server/settlers.c cleanup 3, Gregory Berkolaiko, 2002/04/16
- 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
|
|