Complete.Org: Mailing Lists: Archives: freeciv-ai: August 2004:
[freeciv-ai] (PR#9615) AI-specific functions in citytools.c
Home

[freeciv-ai] (PR#9615) AI-specific functions in citytools.c

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: undisclosed-recipients: ;
Subject: [freeciv-ai] (PR#9615) AI-specific functions in citytools.c
From: "Gregory Berkolaiko" <Gregory.Berkolaiko@xxxxxxxxxxxxx>
Date: Thu, 5 Aug 2004 13:04:09 -0700
Reply-to: rt@xxxxxxxxxxx

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

Many functions in server/citytools.c are only used by the AI and are not
especially tied to the server.  Here is a list (probably incomplete):
1. is_worked_here (not used)
2. food_weighting
3. city_tile_value
4. worst_worker_tile_value
5. best_worker_tile_value
6. built_elsewhere
7. is_building_other_wonder

In the attached patch I move the more obvious 6 and 7 and remove 1.

G.
? ttt.gz
? ai/aiexplorer.c
? ai/aiexplorer.h
Index: ai/advdomestic.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/ai/advdomestic.c,v
retrieving revision 1.112
diff -u -r1.112 advdomestic.c
--- ai/advdomestic.c    5 Aug 2004 11:42:09 -0000       1.112
+++ ai/advdomestic.c    5 Aug 2004 19:56:18 -0000
@@ -396,6 +396,22 @@
   return cost;
 }
 
+/****************************************************************************
+  Return TRUE if the given wonder has been built by pcity owner somewhere 
+  other than in pcity.
+****************************************************************************/
+static bool built_elsewhere(struct city *pcity, Impr_Type_id wonder)
+{
+  city_list_iterate(city_owner(pcity)->cities, acity) {
+    if (pcity != acity && !acity->is_building_unit
+       && pcity->currently_building == wonder) {
+      return TRUE;
+    }
+  } city_list_iterate_end;
+
+  return FALSE;
+}
+
 /**************************************************************************
   Evaluate the current desirability of all city improvements for the given 
   city to update pcity->ai.building_want.
Index: ai/aitools.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/ai/aitools.c,v
retrieving revision 1.116
diff -u -r1.116 aitools.c
--- ai/aitools.c        5 Aug 2004 11:34:18 -0000       1.116
+++ ai/aitools.c        5 Aug 2004 19:56:18 -0000
@@ -695,7 +695,29 @@
 }
 
 /**************************************************************************
-...
+  Returns TRUE if pcity's owner is building wonder in another city on the
+  same continent.
+**************************************************************************/
+static bool is_building_other_wonder(struct city *pcity)
+{
+  struct player *pplayer = city_owner(pcity);
+
+  city_list_iterate(pplayer->cities, acity) {
+    if ((pcity != acity) 
+        && !acity->is_building_unit
+        && is_wonder(acity->currently_building) 
+        && (map_get_continent(acity->x, acity->y)
+            == map_get_continent(pcity->x, pcity->y))) {
+      return TRUE;
+    }
+  } city_list_iterate_end;
+
+  return FALSE;
+}
+
+/**************************************************************************
+  Choose improvement we like most and put it into ai_choice.
+  TODO: Clean, update the log calls.
 **************************************************************************/
 void ai_advisor_choose_building(struct city *pcity, struct ai_choice *choice)
 { /* I prefer the ai_choice as a return value; gcc prefers it as an arg -- 
Syela */
Index: server/citytools.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/server/citytools.c,v
retrieving revision 1.267
diff -u -r1.267 citytools.c
--- server/citytools.c  5 Aug 2004 11:34:18 -0000       1.267
+++ server/citytools.c  5 Aug 2004 19:56:19 -0000
@@ -550,44 +550,6 @@
 }
 
 /**************************************************************************
-...
-**************************************************************************/
-bool is_building_other_wonder(struct city *pc)
-{
-  struct player *pplayer = city_owner(pc);
-
-  city_list_iterate(pplayer->cities, pcity) {
-    if ((pc != pcity) 
-        && !pcity->is_building_unit
-        && is_wonder(pcity->currently_building) 
-        && (map_get_continent(pcity->x, pcity->y)
-            == map_get_continent(pc->x, pc->y))) {
-      return TRUE;
-    }
-  } city_list_iterate_end;
-
-  return FALSE;
-}
-
-/****************************************************************************
-  Return TRUE iff the given wonder has been built somewhere other than in
-  the given city.
-****************************************************************************/
-bool built_elsewhere(struct city *pc, Impr_Type_id wonder)
-{
-  struct player *pplayer = city_owner(pc);
-
-  city_list_iterate(pplayer->cities, pcity) {
-    if (pc != pcity && !pcity->is_building_unit
-       && pcity->currently_building == wonder) {
-      return TRUE;
-    }
-  } city_list_iterate_end;
-
-  return FALSE;
-}
-
-/**************************************************************************
   Will unit of this type be created as veteran?
 **************************************************************************/
 int do_make_unit_veteran(struct city *pcity, Unit_Type_id id)
Index: server/citytools.h
===================================================================
RCS file: /home/freeciv/CVS/freeciv/server/citytools.h,v
retrieving revision 1.53
diff -u -r1.53 citytools.h
--- server/citytools.h  20 Jul 2004 09:55:43 -0000      1.53
+++ server/citytools.h  5 Aug 2004 19:56:19 -0000
@@ -38,8 +38,6 @@
 int food_weighting(int city_size);
 int city_tile_value(struct city *pcity, int x, int y, int foodneed, int 
prodneed);
 int settler_eats(struct city *pcity);
-bool is_building_other_wonder(struct city *pc);
-bool built_elsewhere(struct city *pc, Impr_Type_id wonder);
 int do_make_unit_veteran(struct city *pcity, Unit_Type_id id);
 int city_shield_bonus(struct city *pcity);
 int city_luxury_bonus(struct city *pcity);

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