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]
Subject: [Freeciv-Dev] Re: (PR#12422) stupid AI leaves its city in disorder
From: "Jason Short" <jdorje@xxxxxxxxxxxxxxxxxxxxx>
Date: Thu, 3 Mar 2005 15:10:00 -0800
Reply-to: bugs@xxxxxxxxxxx

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

Per I. Mathisen wrote:
> <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.

Not sure about the bug but your assert is wrong because there is a 
generic_city_refresh call built in at the start of CM.  Here is a more 
comprehensive and correct assert.

-jason

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 23:07:01 -0000
@@ -1793,14 +1793,19 @@
                     struct cm_result *result)
 {
   struct cm_state *state = cm_init_state(pcity);
+  struct city old_city;
 
   /* Refresh the city.  Otherwise the CM can give wrong results or just be
    * slower than necessary.  Note that cities are often passed in in an
    * unrefreshed state (which should probably be fixed). */
   generic_city_refresh(pcity, TRUE, NULL);
 
+  old_city = *pcity;
+
   cm_find_best_solution(state, param, result);
   cm_free_state(state);
+
+  assert(memcmp(&old_city, pcity, sizeof(old_city)) == 0);
 }
 
 /**************************************************************************

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