Complete.Org: Mailing Lists: Archives: freeciv-dev: August 2004:
[Freeciv-Dev] (PR#9866) S1_14: AI fixes
Home

[Freeciv-Dev] (PR#9866) S1_14: AI fixes

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: undisclosed-recipients: ;
Subject: [Freeciv-Dev] (PR#9866) S1_14: AI fixes
From: "Per I. Mathisen" <per@xxxxxxxxxxx>
Date: Sun, 29 Aug 2004 13:40:30 -0700
Reply-to: rt@xxxxxxxxxxx

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

This is a subset of the recent AI bugfixes to cvs head, backported to
S1_14. I think we should consider putting this in and do another beta
before we do 1.14.2. The bugs are rather big, IMHO.

  - Per

Index: ai/aiunit.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/ai/aiunit.c,v
retrieving revision 1.221.2.4
diff -u -r1.221.2.4 aiunit.c
--- ai/aiunit.c 2 Jan 2003 15:56:32 -0000       1.221.2.4
+++ ai/aiunit.c 29 Aug 2004 20:36:26 -0000
@@ -635,7 +635,7 @@
   if (pcity->owner != punit->owner) return FALSE;
 
   unit_list_iterate(map_get_tile(pcity->x, pcity->y)->units, pdef) {
-    if (assess_defense_unit(pcity, punit, FALSE) >= 0
+    if (assess_defense_unit(pcity, pdef, FALSE) >= 0
        && pdef != punit
        && pdef->homecity == pcity->id) {
       has_defense = TRUE;
@@ -645,11 +645,10 @@
   /* Guess I better stay / you can live at home now */
   if (!has_defense && pcity->ai.danger > 0) {
     /* change homecity to this city */
-    if (ai_unit_make_homecity(punit, pcity)) {
-      /* Very important, or will not stay -- Syela */
-      ai_unit_new_role(punit, AIUNIT_DEFEND_HOME);
-      return TRUE;
-    }
+    (void) ai_unit_make_homecity(punit, pcity);
+    /* Very important, or will not stay -- Syela */
+    ai_unit_new_role(punit, AIUNIT_DEFEND_HOME);
+    return TRUE;
   }
   return FALSE;
 }
@@ -1401,7 +1400,11 @@
       continue;
     }
     dist = unit_move_turns(punit, buddy->x, buddy->y);
-    def = (toughness - unit_vulnerability_virtual(buddy)) >> dist;
+    def = (toughness - unit_vulnerability_virtual(buddy));
+    if (def <= 0) {
+      continue;
+    }
+    def = def >> dist;
     freelog(LOG_DEBUG, "(%d,%d)->(%d,%d), %d turns, def=%d",
            punit->x, punit->y, buddy->x, buddy->y, dist, def);
 
@@ -1426,7 +1429,11 @@
       continue; 
     }
     dist = unit_move_turns(punit, mycity->x, mycity->y);
-    def = (mycity->ai.danger - assess_defense_quadratic(mycity)) >> dist;
+    def = (mycity->ai.danger - assess_defense_quadratic(mycity));
+    if (def <= 0) {
+      continue;
+    }
+    def = def >> dist;
     if (def > best && ai_fuzzy(pplayer, TRUE)) { 
       *acity = mycity; 
       best = def; 

[Prev in Thread] Current Thread [Next in Thread]
  • [Freeciv-Dev] (PR#9866) S1_14: AI fixes, Per I. Mathisen <=