Complete.Org: Mailing Lists: Archives: freeciv-ai: November 2005:
[freeciv-ai] Re: (PR#14368) AI concentrates its navy around huts.
Home

[freeciv-ai] Re: (PR#14368) AI concentrates its navy around huts.

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: mstefek@xxxxxxxxx
Subject: [freeciv-ai] Re: (PR#14368) AI concentrates its navy around huts.
From: "Per I. Mathisen" <per@xxxxxxxxxxx>
Date: Wed, 2 Nov 2005 10:24:56 -0800
Reply-to: bugs@xxxxxxxxxxx

<URL: http://bugs.freeciv.org/Ticket/Display.html?id=14368 >

On Tue, 18 Oct 2005, Mateusz Stefek wrote:
> In the attached savegame iroquis concentrate its large navy around huts
> on arctic. Mongols do the same on the south pole.
>
> Do they think that they can take those huts ?

Yup!

Patches attached. One for the bugfix, and one to help track down such
bugs.

  - Per

Index: ai/aiunit.c
===================================================================
--- ai/aiunit.c (revision 11214)
+++ ai/aiunit.c (working copy)
@@ -579,16 +579,14 @@
     /* ...and free foreign city waiting for us. Who would resist! */
     if (pcity && pplayers_at_war(pplayer, city_owner(pcity))
         && COULD_OCCUPY(punit)) {
-      
       return -RAMPAGE_FREE_CITY_OR_BETTER;
     }
     
     /* ...or tiny pleasant hut here! */
-    if (tile_has_special(ptile, S_HUT) && !is_barbarian(pplayer)) {
-      
+    if (tile_has_special(ptile, S_HUT) && !is_barbarian(pplayer)
+        && is_ground_unit(punit)) {
       return -RAMPAGE_HUT_OR_BETTER;
     }
-    
   }
   
   return 0;
Index: ai/aiunit.c
===================================================================
--- ai/aiunit.c (revision 11214)
+++ ai/aiunit.c (working copy)
@@ -1043,6 +1041,8 @@
       } else {
         (void) ai_gothere(pplayer, punit, pcity->tile);
       }
+    } else {
+      UNIT_LOG(LOG_VERBOSE, punit, "defending nothing...?");
     }
   }
 }
@@ -1746,6 +1755,7 @@
   pcity = find_nearest_safe_city(punit);
   if (is_sailing_unit(punit) && pcity) {
     /* Sail somewhere */
+    UNIT_LOG(LOG_DEBUG, punit, "sailing to nearest safe house.");
     (void) ai_unit_goto(punit, pcity->tile);
   } else if (!is_barbarian(pplayer)) {
     /* Nothing else to do, so try exploring. */
@@ -1757,9 +1767,11 @@
   } else {
     /* You can still have some moves left here, but barbarians should
        not sit helplessly, but advance towards nearest known enemy city */
+    UNIT_LOG(LOG_DEBUG, punit, "attack: barbarian");
     ai_military_attack_barbarian(pplayer, punit);
   }
   if ((punit = find_unit_by_id(id)) && punit->moves_left > 0) {
+    UNIT_LOG(LOG_DEBUG, punit, "attack: giving up unit to defense");
     ai_military_defend(pplayer, punit);
   }
 }
@@ -2077,6 +2094,7 @@
 
   /* Don't manage the unit if it is under human orders. */
   if (unit_has_orders(punit)) {
+    UNIT_LOG(LOG_VERBOSE, punit, "is under human orders, aborting AI 
control.");
     punit->ai.ai_role = AIUNIT_NONE;
     punit->ai.done = TRUE;
     return;
@@ -2147,11 +2165,14 @@
     return;
   } else if (is_military_unit(punit)) {
     TIMING_LOG(AIT_MILITARY, TIMER_START);
+    UNIT_LOG(LOG_DEBUG, punit, "recruit unit for the military");
     ai_manage_military(pplayer,punit); 
     TIMING_LOG(AIT_MILITARY, TIMER_STOP);
     return;
   } else {
     int id = punit->id;
+
+    UNIT_LOG(LOG_DEBUG, punit, "fell through all unit tasks, defending");
     /* what else could this be? -- Syela */
     if (!ai_manage_explorer(punit)
         && find_unit_by_id(id)) {

[Prev in Thread] Current Thread [Next in Thread]
  • [freeciv-ai] Re: (PR#14368) AI concentrates its navy around huts., Per I. Mathisen <=