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


> On Fri, 9 Feb 2007, Frank Balbach wrote:
>   
>> I believe the function adjust_building_wants_by_effects() may not always
>> work as intendend (but then I might get the intention wrong).
>>     
> ...
>   
>> If the developers in charge agree with the above, I would happily
>> provide some patches.
>>     
>
> Is this only for 2.1? If so, I'd say we should do as little changes as 
> possible, even if it means the AI will not build harbours.
>
> Could you check how things fare in the SVN trunk (ie the to-be-2.2)?
>   

In the SVN trunk, things are similar as described in my first posting 
for 2.1 although adjust_building_wants... is now called 
adjust_improvement_wants... and the variable "useful" has been renamed 
to "active".

I'd like to stress that IMO the AI builds harbours reasonably well (both 
in trunk and in 2.1) and that my proposed changes do not at all effect 
the behavior of the AI (except maybe in very customised rulesets).

My main intention was to make the code behave in a slightly more 
transparent way.  Therefore, it probably suffices to apply the changes 
to SVN trunk only (if at all).

Anyway, I've created some patches:  "harboureffect" patches aicity.c, 
"effruleset" patches "effects.ruleset".  The patches with "21" apply to 
2.1, the other ones to trunk (revision 12645 in both cases).

Frank


--- effects.ruleset.orig	2007-02-13 11:21:48.000000000 +0100
+++ effects.ruleset	2007-02-13 11:45:40.000000000 +0100
@@ -967,7 +967,7 @@
 value	= 1
 reqs	=
     { "type", "name", "range"
-      "Terrain", "Ocean", "Local"
+      "Terrain", "Ocean", "Adjacent"
       "Building", "Harbour", "City"
       "OutputType", "Food", "Local"
     }
@@ -1138,7 +1138,7 @@
 value	= 1
 reqs	=
     { "type", "name", "range"
-      "Terrain", "Ocean", "Local"
+      "Terrain", "Ocean", "Adjacent"
       "Building", "Offshore Platform", "City"
       "OutputType", "Shield", "Local"
     }
--- effects.ruleset.orig	2007-02-13 12:02:08.000000000 +0100
+++ effects.ruleset	2007-02-13 12:01:54.000000000 +0100
@@ -948,7 +948,7 @@
 value	= 1
 reqs	=
     { "type", "name", "range"
-      "Terrain", "Ocean", "Local"
+      "Terrain", "Ocean", "Adjacent"
       "Building", "Harbour", "City"
       "OutputType", "Food", "Local"
     }
@@ -1119,7 +1119,7 @@
 value	= 1
 reqs	=
     { "type", "name", "range"
-      "Terrain", "Ocean", "Local"
+      "Terrain", "Ocean", "Adjacent"
       "Building", "Offshore Platform", "City"
       "OutputType", "Shield", "Local"
     }
--- aicity.c.orig	2007-02-13 11:00:28.000000000 +0100
+++ aicity.c	2007-02-13 11:48:50.000000000 +0100
@@ -805,7 +805,7 @@
     struct tech_vector needed_techs;
 
     if (is_effect_disabled(pplayer, pcity, pimpr,
-			   NULL, NULL, NULL, NULL,
+			   pcity->tile, NULL, NULL, NULL,
 			   peffect)) {
       continue;
     }
@@ -820,7 +820,10 @@
 	mypreq = preq;
         continue;
       }
-      if (!is_req_active(pplayer, pcity, pimpr, NULL, NULL, NULL, NULL,
+      if (preq->source.type == REQ_OUTPUTTYPE) {
+        continue;
+      }
+      if (!is_req_active(pplayer, pcity, pimpr, pcity->tile, NULL, NULL, NULL,
 			 preq)) {
 	active = FALSE;
 	if (preq->source.type == REQ_TECH) {
--- aicity.c.orig	2007-02-13 11:57:52.000000000 +0100
+++ aicity.c	2007-02-13 12:00:55.000000000 +0100
@@ -306,7 +306,7 @@
     bool useful;
 
     if (is_effect_disabled(pplayer, pcity, pimpr,
-			   NULL, NULL, NULL, NULL,
+			   ptile, NULL, NULL, NULL,
 			   peffect)) {
       CITY_LOG(LOG_DEBUG, pcity, "%s has a disabled effect: %s", 
                get_improvement_name(id), effect_type_name(peffect->type));
@@ -323,7 +323,10 @@
 	mypreq = preq;
         continue;
       }
-      if (!is_req_active(pplayer, pcity, pimpr, NULL, NULL, NULL, NULL,
+      if (preq->source.type == REQ_OUTPUTTYPE) {
+        continue;
+      }
+      if (!is_req_active(pplayer, pcity, pimpr, ptile, NULL, NULL, NULL,
 			 preq)) {
 	useful = FALSE;
 	break;
_______________________________________________
Freeciv-dev mailing list
Freeciv-dev@gna.org
https://mail.gna.org/listinfo/freeciv-dev

Reply via email to