Complete.Org: Mailing Lists: Archives: freeciv-dev: March 2005:
[Freeciv-Dev] Re: (PR#12422) stupid AI leaves its city in disorder
Home

[Freeciv-Dev] Re: (PR#12422) stupid AI leaves its city in disorder

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: jdorje@xxxxxxxxxxxxxxxxxxxxx
Subject: [Freeciv-Dev] Re: (PR#12422) stupid AI leaves its city in disorder
From: "Per I. Mathisen" <per@xxxxxxxxxxx>
Date: Thu, 3 Mar 2005 14:57:59 -0800
Reply-to: bugs@xxxxxxxxxxx

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

On Wed, 2 Mar 2005, Jason Short wrote:
> When the game was saved Zurich was in disorder, and had been so for many
> turns.On loading the game the CM seems to be run.  However you can
> manually place the worker back on the map to return the city to disorder.
>
> The AI never fixes this disorder.I'm pretty positive the reason is
> that aaw is never called.The city (which is of size 4) must have been
> put into disorder by the founding of a city elsewhere in the civ.Since
> nothing else has ever changed I guess there's nothing to trigger an
> auto_arrange_workers call.

No, the AI will run aaw on any city in disorder. The problem is that
ai_manage_cities() thinks the city is not in disorder, and from looking at
the city data from this function, this is correct. When the AI is called,
the city is not revolting.

The city is set to a false happiness status in the AI tax code, when this
code queries CM for a possible celebration state. The AI does not use the
CM to intentionally change city state here, so clearly there is some bad
side effects taking place from the CM query, as demonstrated by the
attached assert.

  - Per

Index: common/aicore/cm.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/common/aicore/cm.c,v
retrieving revision 1.58
diff -u -r1.58 cm.c
--- common/aicore/cm.c  7 Jan 2005 02:59:39 -0000       1.58
+++ common/aicore/cm.c  3 Mar 2005 22:56:57 -0000
@@ -1792,6 +1792,7 @@
                     const struct cm_parameter *param,
                     struct cm_result *result)
 {
+  bool was_happy = city_unhappy(pcity);
   struct cm_state *state = cm_init_state(pcity);
 
   /* Refresh the city.  Otherwise the CM can give wrong results or just be
@@ -1801,6 +1802,7 @@
 
   cm_find_best_solution(state, param, result);
   cm_free_state(state);
+  assert(was_happy == city_unhappy(pcity));
 }
 
 /**************************************************************************

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