Complete.Org: Mailing Lists: Archives: freeciv-ai: March 2003:
[freeciv-ai] (PR#3619) coordinate fix in find_city_to_diplomat
Home

[freeciv-ai] (PR#3619) coordinate fix in find_city_to_diplomat

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: undisclosed-recipients:;
Subject: [freeciv-ai] (PR#3619) coordinate fix in find_city_to_diplomat
From: "Jason Short" <jdorje@xxxxxxxxxxxxxxxxxxxxx>
Date: Fri, 14 Mar 2003 18:37:46 -0800
Reply-to: rt@xxxxxxxxxxxxxx

[rwetmore@xxxxxxxxxxxx - Sat Mar  8 13:12:52 2003]:

> Per has the right understanding. The value does not need to be
> an upper bound on any map distance. It may in fact make more
> sense to limit it to 10 or 20 moves, i.e. a reasonable range
> the diplomat can reach in reasonable time.
> 
> But Jason is right in that it mixes coordinate concepts. For
> this it should at least have a comment that explains why it
> doesn't matter in this case.

Exactly.  But, in this case the use of map.*size is completely
unnecessary; it is just noise.  The attached patch (updated for PF)
removes this.

jason

Index: ai/aidiplomat.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/ai/aidiplomat.c,v
retrieving revision 1.15
diff -u -r1.15 aidiplomat.c
--- ai/aidiplomat.c     2003/03/11 18:49:14     1.15
+++ ai/aidiplomat.c     2003/03/15 02:32:46
@@ -315,7 +315,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);
@@ -352,10 +352,14 @@
             || (incite_cost < (pplayer->economic.gold - pplayer->ai.est_upkeep)
                 && can_incite && !dipldef))) {
       /* We have the closest enemy city so far on the same continent */
+      /* The first target found will initialize both ctarget (from NULL)
+       * and best_dist (from -1). */
       *ctarget = acity;
       *move_dist = pos.total_MC;
     }
   } simple_unit_path_iterator_end;
+
+  assert(*ctarget == NULL || *move_dist >= 0);
 }
 
 /**************************************************************************

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