Complete.Org: Mailing Lists: Archives: freeciv-dev: August 2004:
[Freeciv-Dev] Re: (PR#9624) remove ugliness from ai_calc_pollution/fallo
Home

[Freeciv-Dev] Re: (PR#9624) remove ugliness from ai_calc_pollution/fallo

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: undisclosed-recipients: ;
Subject: [Freeciv-Dev] Re: (PR#9624) remove ugliness from ai_calc_pollution/fallout
From: "Jason Short" <jdorje@xxxxxxxxxxxxxxxxxxxxx>
Date: Fri, 6 Aug 2004 09:48:32 -0700
Reply-to: rt@xxxxxxxxxxx

<URL: http://rt.freeciv.org/Ticket/Display.html?id=9624 >

Jason Short wrote:
> <URL: http://rt.freeciv.org/Ticket/Display.html?id=9624 >
> 
> ai_calc_pollution and ai_calc_fallout has a rather ugly hack to make 
> sure that pollution and fallout are cleaned up.  However this isn't 
> necessary since there's already a mechanism in place for making sure of 
> that: pplayer->ai.warmth (either 50 or 100, a truly huge value) is 
> passed as the "extra" (bonus) value for this action to 
> consider_settler_action.
> 
> This patch simply removes the original hack.  I believe this makes 
> best_worker_tile_value unused but I didn't remove it (note that there's 
> a bug in best_worker_tile_value causing it to really return the worst 
> tile value, see PR#9615).

Now that best_worker_tile_value is static, this patch also removes it.

jason

Index: server/settlers.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/server/settlers.c,v
retrieving revision 1.191
diff -u -r1.191 settlers.c
--- server/settlers.c   6 Aug 2004 16:46:24 -0000       1.191
+++ server/settlers.c   6 Aug 2004 16:47:35 -0000
@@ -257,9 +257,13 @@
   should be compared to the goodness of the tile currently (see
   city_tile_value(); note that this depends on the AI's weighting
   values).
+
+  This function does not calculate the global benefit if cleaning up
+  pollution (reduced global warning).  That is stored as a constant
+  bonus in pplayer->ai.warmth.
 **************************************************************************/
 static int ai_calc_pollution(struct city *pcity, int city_x, int city_y,
-                            int best, int map_x, int map_y)
+                            int map_x, int map_y)
 {
   int goodness;
 
@@ -270,9 +274,6 @@
   goodness = city_tile_value(pcity, city_x, city_y, 0, 0);
   map_set_special(map_x, map_y, S_POLLUTION);
 
-  /* FIXME: need a better way to guarantee pollution is cleaned up. */
-  goodness = (goodness + best + 50) * 2;
-
   return goodness;
 }
 
@@ -286,9 +287,12 @@
   should be compared to the goodness of the tile currently (see
   city_tile_value(); note that this depends on the AI's weighting
   values).
+
+  This function does not calculate the global benefit if cleaning up
+  fallout (reduced nuclear winter).  That is stored as a constant
+  bonus in pplayer->ai.warmth.
 **************************************************************************/
-static int ai_calc_fallout(struct city *pcity, struct player *pplayer,
-                          int city_x, int city_y, int best,
+static int ai_calc_fallout(struct city *pcity, int city_x, int city_y,
                           int map_x, int map_y)
 {
   int goodness;
@@ -300,11 +304,6 @@
   goodness = city_tile_value(pcity, city_x, city_y, 0, 0);
   map_set_special(map_x, map_y, S_FALLOUT);
 
-  /* FIXME: need a better way to guarantee fallout is cleaned up. */
-  if (!pplayer->ai.control) {
-    goodness = (goodness + best + 50) * 2;
-  }
-
   return goodness;
 }
 
@@ -1175,27 +1174,6 @@
 #undef LOG_SETTLER
 
 /**************************************************************************
-  Returns city_tile_value of the best tile worked by or available to pcity.
-**************************************************************************/
-static int best_worker_tile_value(struct city *pcity)
-{
-  int best = 0;
-
-  city_map_iterate(x, y) {
-    if (is_city_center(x, y) 
-       || get_worker_city(pcity, x, y) == C_TILE_WORKER 
-       || get_worker_city(pcity, x, y) == C_TILE_EMPTY) {
-      int tmp = city_tile_value(pcity, x, y, 0, 0);
-
-      if (tmp > best) {
-       best = tmp;
-      }
-    }
-  } city_map_iterate_end;
-  return best;
-}
-
-/**************************************************************************
   Do all tile improvement calculations and cache them for later.
 
   These values are used in evaluate_improvements() so this function must
@@ -1205,8 +1183,6 @@
 void initialize_infrastructure_cache(struct player *pplayer)
 {
   city_list_iterate(pplayer->cities, pcity) {
-    int best = best_worker_tile_value(pcity);
-
     city_map_iterate(city_x, city_y) {
       pcity->ai.detox[city_x][city_y] = -1;
       pcity->ai.derad[city_x][city_y] = -1;
@@ -1220,9 +1196,9 @@
     city_map_checked_iterate(pcity->x, pcity->y,
                             city_x, city_y, map_x, map_y) {
       pcity->ai.detox[city_x][city_y]
-       = ai_calc_pollution(pcity, city_x, city_y, best, map_x, map_y);
-      pcity->ai.derad[city_x][city_y] =
-       ai_calc_fallout(pcity, pplayer, city_x, city_y, best, map_x, map_y);
+       = ai_calc_pollution(pcity, city_x, city_y, map_x, map_y);
+      pcity->ai.derad[city_x][city_y]
+       = ai_calc_fallout(pcity, city_x, city_y, map_x, map_y);
       pcity->ai.mine[city_x][city_y]
        = ai_calc_mine(pcity, city_x, city_y, map_x, map_y);
       pcity->ai.irrigate[city_x][city_y]

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