Complete.Org: Mailing Lists: Archives: freeciv-ai: April 2003:
[freeciv-ai] (PR#3619) another solution for aidiplomat.c topology issue
Home

[freeciv-ai] (PR#3619) another solution for aidiplomat.c topology issue

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: jdorje@xxxxxxxxxxxxxxxxxxxxx
Subject: [freeciv-ai] (PR#3619) another solution for aidiplomat.c topology issue
From: "Per I. Mathisen" <per@xxxxxxxxxxx>
Date: Fri, 18 Apr 2003 05:58:24 -0700
Reply-to: rt@xxxxxxxxxxxxxx

This patch fixes the topology issue, and also stops the iteration earlier.

  - Per

Index: ai/aidiplomat.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/ai/aidiplomat.c,v
retrieving revision 1.16
diff -u -r1.16 aidiplomat.c
--- ai/aidiplomat.c     4 Apr 2003 15:47:45 -0000       1.16
+++ ai/aidiplomat.c     18 Apr 2003 12:56:21 -0000
@@ -314,7 +314,7 @@
 
   assert(punit != NULL);
   *ctarget = NULL;
-  *move_dist = MAX(map.xsize, map.ysize);
+  *move_dist = -1;
 
   simple_unit_path_iterator(punit, pos) {
     struct city *acity = map_get_city(pos.x, pos.y);
@@ -344,15 +344,15 @@
      * 1. establishing embassy OR
      * 2. stealing techs OR
      * 3. inciting revolt */
-    if ((!*ctarget || *move_dist > pos.total_MC)
-        && (!has_embassy
-            || (acity->steal == 0 && pplayer->research.techs_researched < 
-                city_owner(acity)->research.techs_researched && !dipldef)
-            || (incite_cost < (pplayer->economic.gold - pplayer->ai.est_upkeep)
-                && can_incite && !dipldef))) {
-      /* We have the closest enemy city so far on the same continent */
+    if ((!has_embassy
+          || (acity->steal == 0 && pplayer->research.techs_researched < 
+              city_owner(acity)->research.techs_researched && !dipldef)
+          || (incite_cost < (pplayer->economic.gold - pplayer->ai.est_upkeep)
+              && can_incite && !dipldef))) {
+      /* We have the closest enemy city on the continent */
       *ctarget = acity;
       *move_dist = pos.total_MC;
+      break;
     }
   } simple_unit_path_iterator_end;
 }

[Prev in Thread] Current Thread [Next in Thread]
  • [freeciv-ai] (PR#3619) another solution for aidiplomat.c topology issue, Per I. Mathisen <=