Submitted by: cazfi
Submitted on: Sun 19 Jun 2011 02:48:44 AM EEST
Priority: 5 - Normal
Status: Ready For Test
Assigned to: None
Discussion Lock: Any
Planned Release: 2.4.0
Integer math is not really suitable for amortize() kind of operation.
Especially problematic is return value 0. Many callers handle (or rather don't
handle at all) that specially. For example: if best tile improvement thing
settler may do gets want value 0, settler keeps its current, i.e., doing
nothing, state. Obviously it would be better to do just slightly (want value
between 0 and 1) beneficial thing than nothing.
While changing amortize() return value from int to float or double may seem
like correct solution, it would require changing a lot of codebase to use
those types to be really correctly implemented.
Instaed attached patch trades one problem to another, but hopefully less
dramatic, problem. Instead of returning value "0" too often, new function
amortize_abs_zero() returns "1" or "-1" too often. It returns "0" only if
there really is no value in doing something.
This patch needs a lot of testing to see that it really improves, and not
decrease, overall performance of ai.
Date: Sun 19 Jun 2011 02:48:44 AM EEST Name: AmortizeAbsZero.diff Size: 7kB
Reply to this item at:
Message sent via/by Gna!
Freeciv-dev mailing list