Complete.Org: Mailing Lists: Archives: freeciv-ai: October 2004:
[freeciv-ai] (PR#10561) Re: AI starts many wonders but never finishes an
Home

[freeciv-ai] (PR#10561) Re: AI starts many wonders but never finishes an

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: dj67@xxxxxxxxxxxxxxxx
Subject: [freeciv-ai] (PR#10561) Re: AI starts many wonders but never finishes any
From: "Per I. Mathisen" <per@xxxxxxxxxxx>
Date: Sat, 30 Oct 2004 08:16:36 -0700
Reply-to: rt@xxxxxxxxxxx

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

Here is a patch to improve this problem: Make AI advisor (used when
production finished for both human and AI) use the proper function that
is used by the AI to change productions. This limits the number of
wonders built at the same time to one, as before. Other cities may build
caravans.

  - Per
Index: server/cityturn.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/server/cityturn.c,v
retrieving revision 1.269
diff -u -r1.269 cityturn.c
--- server/cityturn.c   19 Oct 2004 06:46:57 -0000      1.269
+++ server/cityturn.c   30 Oct 2004 15:00:33 -0000
@@ -52,6 +52,7 @@
 #include "aicity.h"
 #include "aidata.h"
 #include "ailog.h"
+#include "aitools.h"
 
 #include "cityturn.h"
 
@@ -565,19 +566,12 @@
 **************************************************************************/
 void advisor_choose_build(struct player *pplayer, struct city *pcity)
 {
-  Impr_Type_id id = -1;
-  int val = 0;
+  struct ai_choice choice;
 
   /* See what AI has to say */
-  impr_type_iterate(i) {
-    if (pcity->ai.building_want[i] > val
-        && can_build_improvement(pcity, i)) {
-      val = pcity->ai.building_want[i];
-      id = i;
-    }
-  } impr_type_iterate_end;
-  if (id >= 0 && id < B_LAST) {
-    change_build_target(pplayer, pcity, id, FALSE, E_IMP_AUTO);
+  ai_advisor_choose_building(pcity, &choice);
+  if (choice.choice >= 0 && choice.choice < B_LAST) {
+    change_build_target(pplayer, pcity, choice.choice, FALSE, E_IMP_AUTO);
     return;
   }
 

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