Complete.Org: Mailing Lists: Archives: freeciv-dev: March 2006:
[Freeciv-Dev] (PR#15977) Domestic advisor builds redundant buildings
Home

[Freeciv-Dev] (PR#15977) Domestic advisor builds redundant buildings

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
Subject: [Freeciv-Dev] (PR#15977) Domestic advisor builds redundant buildings
From: "Guillaume Melquiond" <guillaume.melquiond@xxxxxxxxx>
Date: Sat, 18 Mar 2006 15:53:37 -0800
Reply-to: bugs@xxxxxxxxxxx

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

For example, although the player has built Michelangelo's Chapel and
Women's Suffrage, whenever a city has nothing left in its worklist,
the advisor will try to build cathedrals and police stations instead
of capitalizing or working on a less useless building. This is a
really annoying feature.

As far as I understand it, it's because all the ai.building_wants are
0, so the advisor just choose the first legal one, even if it is
redundant. The attached patch fixes it by setting all
ai.building_wants to a positive value. The domestic advisor will then
set to 0 all the redundant improvements. As a consequence, the advisor
will not choose redundant buildings, since there will still be
improvements with a positive value like coinage.

Index: ai/aicity.c
===================================================================
--- ai/aicity.c (révision 11781)
+++ ai/aicity.c (copie de travail)
@@ -1060,12 +1060,17 @@
    * if improvements have improvements as requirements.
    */
   city_list_iterate(pplayer->cities, pcity) {
-    if (pplayer->ai.control && pcity->ai.next_recalc <= game.info.turn) {
+    if (!pplayer->ai.control) {
+      /* For a human player, any building is worth building until discarded */
+      impr_type_iterate(id) {
+        pcity->ai.building_want[id] = 1;
+      } impr_type_iterate_end;
+    } else if (pcity->ai.next_recalc <= game.info.turn) {
       /* Do a scheduled recalculation this turn */
       impr_type_iterate(id) {
         pcity->ai.building_want[id] = 0;
       } impr_type_iterate_end;
-    } else if (pplayer->ai.control && should_force_recalc(pcity)) {
+    } else if (should_force_recalc(pcity)) {
       /* Do an emergency recalculation this turn. */
       pcity->ai.recalc_interval = pcity->ai.next_recalc - game.info.turn;
       pcity->ai.next_recalc = game.info.turn;


[Prev in Thread] Current Thread [Next in Thread]
  • [Freeciv-Dev] (PR#15977) Domestic advisor builds redundant buildings, Guillaume Melquiond <=