patchFreeciv - Patches: patch #3697, When city growth is blocked, AI...

Show feedback again

patch #3697: When city growth is blocked, AI shouldn't give any value to food surplus

Submitted by:  Marko Lindqvist <cazfi>
Submitted on:  Wed Feb 13 02:17:56 2013  
Category: aiPriority: 5 - Normal
Status: DonePrivacy: Public
Assigned to: Marko Lindqvist <cazfi>Open/Closed: Closed
Planned Release: 2.6.0Contains string changes: None

Add a New Comment (Rich MarkupRich Markup):

You are not logged in

Please log in, so followups can be emailed to you.


Wed Apr 9 21:04:20 2014, SVN revision 24752:

When AI cannot grow due to aqueduct size limit and already has full foodbox,
prefer shield production over food production that would make no difference whatsoever.

Patch by Emmet Hikory

See patch #3697

(Browse SVN revision 24752)

Marko Lindqvist <cazfi>
Project AdministratorIn charge of this item.
Sun Mar 23 05:12:35 2014, comment #4:

Excellent catch: I hadn't considered the possibility that a ruleset might require an improvement for cities to grow beyond size 1: I didn't actually test what would happen: code inspection led me to believe it would set the value from the -1 entry in an array, which is unlikely to be a useful value, if something doesn't spew an array bounds error. Updated patch attached hardcoding granary size to 0 for size 0 cities (either there isn't such a thing as a size 0 city, or the rats eat all the stored grain when nobody lives there). Also added the space: I've clearly been reading non-freeciv code more than freeciv code lately :)

(file #20421)

Emmet Hikory <persia>
Project Member
Sun Mar 23 02:26:37 2014, comment #3:

- "if(" -> "if ("
- If ruleset has aqueduct_size = 1, and thus cities of size 1 can end here:
extra_food += pcity->food_stock -
city_granary_size(city_size_get(pcity) - 1);
What does city_granary_size(1 - 1) do?

Marko Lindqvist <cazfi>
Project AdministratorIn charge of this item.
Thu Mar 20 03:47:38 2014, comment #2:

Patch rebased against r24699

(file #20391)

Emmet Hikory <persia>
Project Member
Wed Apr 24 04:30:08 2013, comment #1:

Attached is a patch that seems to work for me. Note that the increase in appeal for the improvements is essential here: early revisions of the patch didn't include that, with the result that when the granary was full, the AI deprioritised food, and then happily decided it didn't need that Aqueduct/Sewer System so much after all, with the result that cities ended up capped at size 8. It still sometimes builds other things in preference to the EFT_SIZE_ADJ improvement, but it gets around to it after what seems a reasonable time, making me think the adjustment factor isn't horridly imbalanced. It may be that we don't need to always rearrange workers with a full granary as if it was an emergency, but not doing so seemed to cause long delays in the AI deciding to actually use more production during my testing.

(file #17823)

Emmet Hikory <persia>
Project Member
Wed Feb 13 02:17:56 2013, original submission:

Noticed size 8 AI city building Aqueduct. It had still arranged workers for food surplus (that went to waste) and not for shields (which would speed Aqueduct building).

Marko Lindqvist <cazfi>
Project AdministratorIn charge of this item.


(Note: upload size limit is set to 1024 kB, after insertion of the required escape characters.)

Attach File(s):

Attached Files


Depends on the following items: None found

Items that depend on this one: None found


Carbon-Copy List
  • -unavailable- added by persia (Updated the item)
  • -unavailable- added by cazfi (Submitted the item)

    Do you think this task is very important?
    If so, you can click here to add your encouragement to it.
    This task has 0 encouragements so far.

    Only logged-in users can vote.


    Error: not logged in



    Follow 8 latest changes.

    Date Changed By Updated Field Previous Value => Replaced By
    Wed Apr 9 21:04:35 2014cazfiStatusReady For Test=>Done
    Wed Mar 26 23:04:53 2014cazfiStatusNone=>Ready For Test
      Assigned toNone=>cazfi
      Planned Release=>2.6.0
    Sun Mar 23 05:12:35 2014persiaAttached File-=>Added reduce-food-interest-with-full-granary+size1aqueduct.patch, #20421
    Thu Mar 20 03:47:37 2014persiaAttached File-=>Added reduce-food-interest-with-full-granary+rebase.patch, #20391
    Wed Apr 24 04:30:08 2013persiaAttached File-=>Added reduce-food-interest-with-full-granary.patch, #17823
    Show feedback again

    Back to the top

    Powered by Savane 3.1-cleanup