Complete.Org: Mailing Lists: Archives: freeciv-ai: August 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: Sun, 31 Aug 2003 05:48:44 -0700
Reply-to: rt@xxxxxxxxxxxxxx

On Sun, 31 Aug 2003, Gregory Berkolaiko wrote:

> This was discussed over IRC and we came to an agreement that AI
> activities should be all performed in one place, either in the end of
> the turn or in the beginning.  Now I started implementing it and thought
> of a good reason not to do it.
> 
> It has to do with urgent purchase of defenders.
> 
> If AI moves in the end:
> Imagine an AI warrior moves up to your empty city.  Next turn, you go to
> that city and buy a phalanx.  However, AI gets to move before the city
> is refreshed and you wasted your money and lost a city.  Human players
> will not be happy with this change.
> 
> If AI moves in the beginning:
> Same situation in reverse, AI does the emergency purchase, but you get
> to move before the purchase takes effect.  Human players will complain
> that AI too stupid.  Of course, it can see under fog and all, but
> emergency pruchase 2 turns in advance might not work very well for AI.
> 
> So the current situation is probably the best: AI moves in the beginning
> of turn and manages cities in the end.  And since we started the whole
> discussion because it was hard to trace when AI moved what unit, all we
> need to do is to make AI _not_ move units in the end of turn.
> 
> A patch will follow shortly.

Here is the patch (couldn't send it through RT, it doesn't give the right 
MIME-type).

The patch 
1. Adds assess_danger before we move units.  It should help to direct 
units to right places.

2. Removes ai_manage_units from after the human turn.

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/08/31 12:26:25
@@ -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: 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/08/31 12:26:26
@@ -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]