Complete.Org: Mailing Lists: Archives: freeciv-dev: April 2005:
[Freeciv-Dev] Re: (PR#12833) consider_settler_action simplification (rev
Home

[Freeciv-Dev] Re: (PR#12833) consider_settler_action simplification (rev

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
Subject: [Freeciv-Dev] Re: (PR#12833) consider_settler_action simplification (rev.)
From: "Brian Dunstan" <bdunstan149@xxxxxxxxx>
Date: Tue, 19 Apr 2005 08:00:18 -0700
Reply-to: bugs@xxxxxxxxxxx

<URL: http://bugs.freeciv.org/Ticket/Display.html?id=12833 >

OK with that one change here is a new patch.



--- Jason Short <jdorje@xxxxxxxxxxxxxxxxxxxxx> wrote:
> 
> <URL:
> http://bugs.freeciv.org/Ticket/Display.html?id=12833
> >
> 
> Brian Dunstan wrote:
> 
> > The easy thing to do would be to drop that
> division. 
> 
> Since that's what's done currently: yes that would
> be the best way.
> 
> -jason


                
__________________________________ 
Do you Yahoo!? 
Plan great trips with Yahoo! Travel: Now over 17,000 guides!
http://travel.yahoo.com/p-travelguide
diff -Nur -Xfreeciv/diff_ignore freeciv/server/settlers.c 
freeciv_altered/server/settlers.c
--- freeciv/server/settlers.c   2005-04-17 13:57:00.255465488 -0400
+++ freeciv_altered/server/settlers.c   2005-04-18 23:35:33.872397080 -0400
@@ -766,39 +766,30 @@
                                    struct tile **best_tile,
                                     struct tile *ptile)
 {
-  int discount_value, base_value = 0;
-  int total_value;
   bool consider;
-
+  int base_value=0, total_value=0;
+  
   if (extra >= 0) {
     consider = TRUE;
   } else {
     consider = (new_tile_value > old_tile_value);
+    extra = 0;
   }
 
+  /* find the present value of the future benefit of this action */
   if (consider) {
-    int diff = new_tile_value - old_tile_value;
+    base_value = new_tile_value - old_tile_value + extra;
+
+    /* use factor to prevent rounding errors */
+    total_value = amortize((1024* base_value), delay);
 
-    /* The 64x is because we are dealing with small ints, usually from 0-20,
-     * which are insufficiently large to use directly in amortize().  Tiles
-     * which are not currently in use do not give us an improvement until
-     * a citizen works them, so they are reduced in value by 1/4. */
-    base_value = diff * (in_use ? 64 : 16) + extra * 64;
-    base_value = MAX(0, base_value);
-
-    discount_value = amortize(base_value, delay);
-
-    /* The total value is (roughly) equal to the base value multiplied by
-     * d / (1 - d), where d is the discount. (discount_value / base value)
-     * The MAX is a guard against the base value being greater or equal
-     * than the discount value, which would only happen if it or the 
-     * delay is <= 0. */
-    total_value = ((discount_value * base_value)
-                  / (MAX(1, base_value - discount_value))) / 64;
+    if(!in_use) {
+      total_value /= 2;
+    }
   } else {
     total_value = 0;
   }
-
+  
   if (total_value > *best_value
       || (total_value == *best_value
          && old_tile_value > *best_old_tile_value)) {

[Prev in Thread] Current Thread [Next in Thread]