URL:
  <http://gna.org/patch/?2733>

                 Summary: amortize_abs_zero()
                 Project: Freeciv
            Submitted by: cazfi
            Submitted on: Sun 19 Jun 2011 02:48:44 AM EEST
                Category: ai
                Priority: 5 - Normal
                  Status: Ready For Test
                 Privacy: Public
             Assigned to: None
        Originator Email: 
             Open/Closed: Open
         Discussion Lock: Any
         Planned Release: 2.4.0

    _______________________________________________________

Details:

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.



    _______________________________________________________

File Attachments:


-------------------------------------------------------
Date: Sun 19 Jun 2011 02:48:44 AM EEST  Name: AmortizeAbsZero.diff  Size: 7kB
  By: cazfi

<http://gna.org/patch/download.php?file_id=13276>

    _______________________________________________________

Reply to this item at:

  <http://gna.org/patch/?2733>

_______________________________________________
  Message sent via/by Gna!
  http://gna.org/


_______________________________________________
Freeciv-dev mailing list
Freeciv-dev@gna.org
https://mail.gna.org/listinfo/freeciv-dev

Reply via email to