Summary: AI assumes all terrain improvement units
(F_SETTLERS) cost population?
                 Project: Freeciv
            Submitted by: jtn
            Submitted on: Sun Feb 17 15:47:07 2013
                Category: ai
                Severity: 3 - Normal
                Priority: 5 - Normal
                  Status: None
             Assigned to: None
        Originator Email: 
             Open/Closed: Open
                 Release: S2_4 r22361
         Discussion Lock: Any
        Operating System: Any
         Planned Release: 



While reviewing patch #3693, I noticed that in
contemplate_terrain_improvements(), this code:

  want = (want - unit_food_upkeep(virtualunit) * FOOD_WEIGHTING / 2) * 100
         / (40 + unit_foodbox_cost(virtualunit));

(which runs in the context of F_SETTLERS units, which actually means terrain
improvers) is I think considering units with a population cost.

However, unit_foodbox_cost() doesn't actually look at the unit type; it seems
to assume that any unit it might be called with has a nonzero pop_cost and
thus consume food from the city when created. Clearly this isn't true of
Workers in the default ruleset.

unit_foodbox_cost() seems bogus in other ways (at least on S2_4):
* If passed a non-virtual unit, it returns a fixed cost of 30. (Fortunately it
never is.)
* Asserts pcity != NULL only after use.
* Doesn't consider pop_cost > 1.
* (I assume the calculation is not referring to the effect on city food of
actually building the unit -- as far as I can tell, there is none beyond
clipping it, which itself isn't accounted for -- but the marginal amount of
food that will be required to get back to where the city would have been had
it not built the unit.)

If these are real issues, I guess that fixing them is likely to mess up
balance / fudge factors.

(Only checked S2_4.)


Reply to this item at:


  Message sent via/by Gna!

Freeciv-dev mailing list

Reply via email to