Complete.Org: Mailing Lists: Archives: freeciv-ai: September 2004:
[freeciv-ai] Re: (PR#10110) AI underestimates Temples
Home

[freeciv-ai] Re: (PR#10110) AI underestimates Temples

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: mstefek@xxxxxxxxx
Subject: [freeciv-ai] Re: (PR#10110) AI underestimates Temples
From: "Jason Short" <jdorje@xxxxxxxxxxxxxxxxxxxxx>
Date: Wed, 15 Sep 2004 08:17:22 -0700
Reply-to: rt@xxxxxxxxxxx

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

Per I. Mathisen wrote:

>>Of course this is hard since you're not allowed to check SP_ELVIS.
> 
> Why are we not allowed to check SP_ELVIS??

In theory, because I want SP_ELVIS go to away.

In actuality, because it won't help.  There used to be (maybe still is) 
code that assumes for every 2 luxury we can get rid of 1 elvis and put 
him to work on the best tile.  Thus for every 2 luxury we get 
ai_calc_best_tile_value() points.  Unfortunately this doesn't work even 
with the current system because the luxury an elvis generates can be 
changed by effects or edited directly in the ruleset.

>>However neither of these is possible for "other" cities. But still
>>there we need to guess at the average bonus, rather than just assuming
>>it to be 1. Probably you can find an average_tile_value() function
>>somewhere and use that, or maybe divide it by 2.
> 
> We can iterate through all cities first, calculate some want for
> happy/content buildings, and store it in pcity->ai.contentwant or
> something.

Are we allowed to do a full recalc here?  This would be quite 
sufficient.  Each city could have a value pcity->ai.contentment[] 
holding an array of goodness for contentment values up to a certain 
level (probably 4).

>>>Granary:
>>>     case EFT_GROWTH_FOOD:
>>>       v += c * 4 + 25;
>>>       break;
>>
>>4 is arbitrary; this should be commented.
>>
>>+25 is meaningless and bad I think...
> 
> 
> This is all arbitrary, and there is no comment that will make it
> meaningful more than /* this seems to work */. I can see if I can come up
> with some better code.

There is an absolute scale.  Any increased output is weighted according 
to the AI weights.

At its core granary just increases food output.  It allows 50% of food 
to be saved when certain things happen.  Thus it basically grants extra 
food at an ammortized rate of food_surplus/2.

So:

   v += pcity->food_surplus * food_weighting(pcity->size) / 2;
   /* Figure on an average surplus of 2, avarage size of 3. */
   v += (c - 1) * food_weighting(3);

it might be useful here to know the average or median size of the cities 
we own.  It might also be useful to cache the food_weighting() values or 
to have a pcity->food_weighting.

However this isn't perfect because the other effects aren't all 
multiplied by their weightings.

Also as a side note some places divide v by MORT.  v should be 
ammortized, but it should be done for all calculations of v.  And for it 
to work it needs to be done everywhere building goodness is calculated 
(miss one place and you'll end up completely breaking things).

jason

Index: ai/aicity.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/ai/aicity.c,v
retrieving revision 1.163
diff -u -r1.163 aicity.c
--- ai/aicity.c 13 Sep 2004 15:54:49 -0000      1.163
+++ ai/aicity.c 15 Sep 2004 15:16:49 -0000
@@ -284,7 +284,9 @@
                * (nplayers - amount)) / (nplayers * amount * 100);
            break;
          case EFT_GROWTH_FOOD:
-           v += c * 4 + 25;
+           v += pcity->food_surplus * food_weighting(pcity->size) / 2;
+           /* Figure on an average surplus of 2, avarage size of 3. */
+           v += (c - 1) * food_weighting(3);
            break;
          case EFT_AIRLIFT:
            v += c + ai->stats.units[UCL_LAND];

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