Complete.Org: Mailing Lists: Archives: freeciv-ai: September 2003:
[freeciv-ai] Re: (PR#5633) Order of AI activities.
Home

[freeciv-ai] Re: (PR#5633) Order of AI activities.

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: per@xxxxxxxxxxx
Subject: [freeciv-ai] Re: (PR#5633) Order of AI activities.
From: "Gregory Berkolaiko" <Gregory.Berkolaiko@xxxxxxxxxxxx>
Date: Thu, 11 Sep 2003 09:40:27 -0700
Reply-to: rt@xxxxxxxxxxxxxx

On Sun, 31 Aug 2003, Per I. Mathisen wrote:

> You need to call ai_manage_units() twice above, to make up for removing it
> from the end of turn. Otherwise units will not be able to disembark from

Yes, now in ai_manage_units I cycle through all units twice.
The new patch is attached.

On Mon, 1 Sep 2003, ue80@xxxxxxxxxxxxxxxxxxxxx wrote:

> I think it's possible to split up some of the AI-activities.
> 
> A human has to rethink about his moved units when he sees new enemy
> units in front of his city. (Double turns)
> 
> And i think the same is true for the AI. When i land with a transport
> full of horses and the AI can't do anything after i've done that the AI
> will never have a chance to beat me. (Ok the same is true for humans
> with AI-double turns ...)

I am working under assumption that when you play against the AI, you want 
a strictly turn-based game.  I certainly do.  And humans don't have a 
chance to react to AIs moves, so why should AI have the privelege?

Best wishes,
G.


Index: ai/aihand.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/ai/aihand.c,v
retrieving revision 1.85
diff -u -r1.85 aihand.c
--- ai/aihand.c 2003/07/14 21:37:03     1.85
+++ ai/aihand.c 2003/09/11 16:34:55
@@ -36,6 +36,7 @@
 #include "spacerace.h"
 #include "unithand.h"
 
+#include "advmilitary.h"
 #include "advspace.h"
 #include "aicity.h"
 #include "aidata.h"
@@ -295,15 +296,27 @@
 }
 
 /**************************************************************************
- Main AI routine.
+  Activities to be done by AI _before_ human turn.  Here we just move the
+  units intelligently.
 **************************************************************************/
 void ai_do_first_activities(struct player *pplayer)
 {
-  ai_manage_units(pplayer); /* STOP.  Everything else is at end of turn. */
+  assess_danger_player(pplayer);
+  /* TODO: Make assess_danger save information on what is threatening
+   * us and make ai_mange_units and Co act upon this information, trying
+   * to eliminate the source of danger */
+
+  ai_manage_units(pplayer); 
+  /* STOP.  Everything else is at end of turn. */
 }
 
 /**************************************************************************
-  ...
+  Activities to be done by AI _after_ human turn.  Here we respond to 
+  dangers created by human and AI opposition by ordering defenders in 
+  cities and setting taxes accordingly.  We also do other duties.  
+
+  We do _not_ move units here, otherwise humans complain that AI moves 
+  twice.
 **************************************************************************/
 void ai_do_last_activities(struct player *pplayer)
 {
Index: ai/aiunit.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/ai/aiunit.c,v
retrieving revision 1.285
diff -u -r1.285 aiunit.c
--- ai/aiunit.c 2003/08/31 17:21:03     1.285
+++ ai/aiunit.c 2003/09/11 16:34:56
@@ -2965,6 +2965,11 @@
   unit_list_iterate_safe(pplayer->units, punit) {
     ai_manage_unit(pplayer, punit);
   } unit_list_iterate_safe_end;
+  /* Sometimes units wait for other units to move so we crudely
+   * solve it by moving everything again */ 
+  unit_list_iterate_safe(pplayer->units, punit) {
+    ai_manage_unit(pplayer, punit);
+  } unit_list_iterate_safe_end;
 }
 
 /**************************************************************************
Index: server/srv_main.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/server/srv_main.c,v
retrieving revision 1.135
diff -u -r1.135 srv_main.c
--- server/srv_main.c   2003/08/09 15:34:19     1.135
+++ server/srv_main.c   2003/09/11 16:34:56
@@ -1495,13 +1495,9 @@
     freelog(LOG_DEBUG, "Season of native unrests");
     summon_barbarians(); /* wild guess really, no idea where to put it, but
                             I want to give them chance to move their units */
+    /* Moved this to after the human turn for efficiency -- Syela */
     freelog(LOG_DEBUG, "Autosettlers");
-    auto_settlers(); /* moved this after ai_start_turn for efficiency -- Syela 
*/
-    /* moved after sniff_packets for even more efficiency.
-       What a guy I am. -- Syela */
-    /* and now, we must manage our remaining units BEFORE the cities that are
-       empty get to refresh and defend themselves.  How totally stupid. */
-    ai_start_turn(); /* Misleading name for manage_units -- Syela */
+    auto_settlers();
     freelog(LOG_DEBUG, "Auto-Attack phase");
     auto_attack();
     freelog(LOG_DEBUG, "Endturn");
@@ -1776,7 +1772,6 @@
       civ_score(pplayer);      /* if we don't, the AI gets really confused */
       if (pplayer->ai.control) {
        set_ai_level_direct(pplayer, pplayer->ai.skill_level);
-        /* assess_danger_player(pplayer); */
       }
     } players_iterate_end;
   }

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