patchFreeciv - Patches: patch #2733, amortize_abs_zero()

 
 
Show feedback again

patch #2733: amortize_abs_zero()

Submitted by:  Marko Lindqvist <cazfi>
Submitted on:  Sat 18 Jun 2011 11:48:44 PM UTC  
 
Category: aiPriority: 5 - Normal
Status: Ready For TestPrivacy: Public
Assigned to: NoneOpen/Closed: Open
Planned Release: 2.5.0

Add a New Comment (Rich MarkupRich Markup):
   

You are not logged in

Please log in, so followups can be emailed to you.

 

Mon 02 Jul 2012 04:36:19 PM UTC, comment #2:

This patch didn't prove beneficial for the ai.

> Obviously it would be better to do just slightly (want value
> between 0 and 1) beneficial thing than nothing.


I will look if it would be feasible to always do even value 0 things instead of nothing. Often what is now of value 0, will be valuable in the future (tile taking to use, some effect's other requirements getting fulfilled)

Marko Lindqvist <cazfi>
Project Administrator
Mon 31 Oct 2011 06:32:10 PM UTC, comment #1:

If this is something for 2.5 would it not be best to do the step to a float? Most of the time amortize is used to calculate a want value which is compared to another value - changes would be only required for some variable definitions (int => float), or?

Matthias Pfafferodt <syntron>
Project Member
Sat 18 Jun 2011 11:48:44 PM UTC, original submission:

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.

Marko Lindqvist <cazfi>
Project Administrator

 

(Note: upload size limit is set to 1024 kB, after insertion of the required escape characters.)

Attach File(s):
   
   
Comment:
   

Attached Files
file #13276:  AmortizeAbsZero.diff added by cazfi (7kB - text/plain)

 

Depends on the following items: None found

Digest:
   patch dependencies.

 

Carbon-Copy List
  • -unavailable- added by syntron (Posted a comment)
  • -unavailable- added by cazfi (Submitted the item)
  •  

    Do you think this task is very important?
    If so, you can click here to add your encouragement to it.
    This task has 0 encouragements so far.

    Only logged-in users can vote.

     

    Please enter the title of George Orwell's famous dystopian book (it's a date):

     

     

    Follow 3 latest changes.

    Date Changed By Updated Field Previous Value => Replaced By
    Sat 30 Jun 2012 04:03:25 PM UTCjtnDependencies-=>patch #2714 is dependent
    Thu 27 Oct 2011 09:50:24 PM UTCcazfiPlanned Release2.4.0=>2.5.0
    Sat 18 Jun 2011 11:48:44 PM UTCcazfiAttached File-=>Added AmortizeAbsZero.diff, #13276
    Show feedback again

    Back to the top


    Powered by Savane 3.1-cleanup