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

[Freeciv-Dev] (PR#9624) remove ugliness from ai_calc_pollution/fallout

[Top] [All Lists]

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

<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).

jason

Index: server/settlers.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/server/settlers.c,v
retrieving revision 1.190
diff -u -r1.190 settlers.c
--- server/settlers.c   6 Aug 2004 10:35:49 -0000       1.190
+++ server/settlers.c   6 Aug 2004 16:21:42 -0000
@@ -179,9 +179,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;
 
@@ -192,9 +196,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;
 }
 
@@ -208,9 +209,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;
@@ -222,11 +226,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;
 }
 
@@ -1106,8 +1105,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;
@@ -1121,9 +1118,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]
  • [Freeciv-Dev] (PR#9624) remove ugliness from ai_calc_pollution/fallout, Jason Short <=