1. We have added a Gift Upgrades feature that allows you to gift an account upgrade to another member, just in time for the holiday season. You can see the gift option when going to the Account Upgrades screen, or on any user profile screen.
    Dismiss Notice

The Curious Cat - City Upkeep Explained

Discussion in 'Civ4 Strategy Articles' started by Gato Loco, Nov 7, 2005.

  1. KrikkitTwo

    KrikkitTwo Immortal

    Joined:
    Apr 3, 2004
    Messages:
    12,316
    Well the Distance maintrenance for the three non-capital cities would probably be 1 (rounding is down in everything in Civ 4 so far), possibly 2 since the formula isn't 100% accurate, but it seems to give higher results rather than lower ones... rounding down that we don't know about.

    # cities maintenence would be
    .9*.3*4=1.08 base meaning
    1.08+0/4=1 for the first city
    1.08+1/4=1 for the second city
    1.08+2/4=1 for the third city
    1.08+3/4=1 for the fourth city

    for a total of 2 maintenance in each non capital city and 1 in the capital
    so on the finance screen
    3= Distance maintenance
    4= # of cities Maintenance

    Civic Maintenance=6
    Government:= 1
    Legal: = 1
    Labor: 0
    Economy:= 2
    Religion:= 2

    For a total of 13 in non-unit pre interest maintenance costs
     
  2. ohioastronomy

    ohioastronomy King

    Joined:
    Dec 14, 2005
    Messages:
    714
    Thanks Krikktone, here is a revised estimate.

    Here is a worked example of what I understand to be the case for Emperor, not organized civ, no luxury resources (e.g. happiness limit is 4 for the capital, 3 for extra cities). I've applied the formulae here and in the civics case (assuming one free maintenance civic and the others low maintenance, civ 4 v 1.52). The first column is the number of cities (assumed pop 4 for capital, pop 3 for others). The second is the assumed distance (I took minimal number for placing cities in a grid such that all tiles could be worked in theory). The third, fourth, and fifth are the cumulative distance cost, cumulative number of cities cost, and cumulative civic maintenance. The last two are the most important: they are the net cost of adding city x and the effective research rate that you get if you have two free maintenance (one from trade, one free) and support maintenance costs with one/two 3 commerce tiles (e.g. village, non-river, non-financial).

    # Cities Dist Distcost Numcity CivicCost Maint CityCost Comm%
    1 0 0 0 2 2 0 85/88
    2 5 2 1 3 6 4 67/75
    3 5 4 2 5 11 5 52/66
    4 5 6 4 6 16 5 43/60
    5 5 8 6 8 22 6 33/54
    6 7.5 11 9 10 30 8 21/46
    7 7.5 14 13 13 40 10 7/38
    8 7.5 17 17 17 51 11 NA/29
    9 7.5 20 21 18 59 8 NA/26
    10 10 24 27 20 71 12 NA/19

    So, if you had a size 4 capital and size 3 colonies; for each city you had one 3-commerce tile; and all other tiles were devoted to other things (hammers/food) you'd be able to support at most 7 cities (at a 7% research rate). If you dedicated 2 tiles to commerce per city, you can postpone (but not avoid) a steep tech plunge; cities 6+ add little. The marginal cost for cities 6+ are high relative to your population base, so the optimal size would be somewhere around 4-5 cities (e.g. you gain little in the early game from having more than this). If you had a higher commerce yield, you'd change this a bit. If you add luxury resources your maintenance rises (but mostly above 4-5 cities). Based on all of this, it looks as if for emperor/not organized the logical breakpoint for early cities is somewhere around 4-5, if I've run the numbers properly..
     
  3. hollebeek

    hollebeek Chieftain

    Joined:
    Dec 17, 2005
    Messages:
    74
    The biggest problems are:

    (1) it doesn't consider placement of other cities. sometimes moving a city
    a little lets you fit in another one that gets the "missed" resource.

    (2) hardly ever considers the benefits of plains hills, fresh waters, or coast
     
  4. Furious

    Furious Chieftain

    Joined:
    Jan 5, 2006
    Messages:
    99
    Location:
    Israel
    Very interesting and precious data.

    I've been thinking about how to turn the information into a rule of thumb on how many cities to found (or to not-raze). So I'm going to say a lot a vague things without numbers, but they might be useful rules in practice.

    I am pretty convinced that after the nineth city, additional cities are unlikely to be paying for themselves in GOLD. Unless they have a lot of commerce, they're probably COSTING you gold.

    HOWEVER, we should ask what the cities are contributing in total, something I call their UTILITY. Cities contribute gold+science+production+resources output+national borders. These things can't be measured in gold (except gold :) ), so you have to try and put a price tag to them in gold equivalents. I'm not even going to try. I'm simply convinced, and I hope the readers are too, that the total utility of a city will offset its maintenence costs well after the ninth city, assuming we're talking about a well-rounded city that's contributing SOMETHING other than its own food. This can be production, commerce, a good resource, etc.

    So when do well-rounded cities' utility stop offsetting their maintenance costs? I'm going to say, without proving it, that this point is well after the fifteenth city. And I don't care how much after, because, you see, I've rarely had more than this number of cities. And if I did, then the game has already been won.

    So my rule of thumb is: if you have less than 15 cities, keep founding / not razing cities, as long as they're in viable locations that can give decent UTILITY. This rule applies most of the time in most of the games. If you have more cities, seriously consider if a new city's total UTILITY is going to offset its cost in gold. This is hard to say! If you have mainenance reducing factors such as courthouses or Versallies, it makes your decision somewhat easier.
     
  5. KrikkitTwo

    KrikkitTwo Immortal

    Joined:
    Apr 3, 2004
    Messages:
    12,316
    Well actually that Can be calculated
    Gold is the equivalent of about 2 commerce (the science+gold factor that CAN be measured in terms of gold)

    The cost of the pop 20 city on Deity level
    I (Interest Factor)
    *( ~10-15 for Civic upkeep from city (pop 20).. assuming 10
    + City # limit 8 .. divide by 2 with courthouse=4
    + Distance Factor .. gets to a max of about 25..10-15 with courthouse)

    so once you have courthouses, the maximum expense of a city is probably about 40 Gold=(~10 Civic, ~10 Distance, ~5 City #) * ~1.6 for Interest (in the mid/late game)... ALL REALLY rough #s

    If that city is all non special Water tiles (the worst really Usable* tile), for a total of ~50 (40 terrain commerce, and probably 10 trade commerce... because of the harbor and the long distances from your own cities), then the Utility ends up being equivalent to 100 Gold once the city has the appropriate improvements (1 Commerce is equivalent to 2 gold once cities are properly built up)... so the net ends up being fairly high, even for a relatively lousy spot (a city with about 7 towns could top that.)

    The issue is the time required, for Towns to grow or Banks, Marketplaces, Libraries, Observatories, etc. to be buit, or populations to grow.

    Every city Will be profitable eventually, in a raw commerce sense, ignoring the hammers, resource access, or other strategic positioning issues. The issue is how Soon it will be profitable (and how expensive it will be in non Gold terms, like military, to hold on to it)

    * I'm not counting Peaks, Ice, Tundra, or Desert as 'usable'.. a city that has an overwhelming amount of those may never be profitable... however those also result in a lower population and so lower cost for the city.
     
  6. KrikkitTwo

    KrikkitTwo Immortal

    Joined:
    Apr 3, 2004
    Messages:
    12,316
    Had to rearrange a formula or two (relooking at the data)

    Distance seems to be (because we only have Normal Map Deity data... I realized I was calculating it based on Normal Difficulty

    [Difficulty Factor*Distance*(Pop+7)/29]

    That 29 is probably some combination of a variety of Map Size factors

    Number seems to be
    [Size%*Diff%*Number of cities*(Pop+17)/18 +City Rank/Number of cities]

    With some rounding probably happening internally (estimates from this are all too high)
     
  7. tveit1

    tveit1 Chieftain

    Joined:
    Feb 23, 2006
    Messages:
    9
    OMG..

    someone get a life...including myself who are playing this...
     
  8. zerza

    zerza Chieftain

    Joined:
    Mar 6, 2003
    Messages:
    12
    Actually the cheesy wheel works great on online games, especially team games. Its a strategy thats been used since PTW.
     
  9. eg577

    eg577 Warlord

    Joined:
    Jun 1, 2002
    Messages:
    211
    The formulas for maintenance start at Line 4,872 in CvCity.cpp. I haven't checked these formulas against any data, this is just deciphering the code and putting it into a presentable form.

    Distance Maintenance
    Here is the tidy formula (ignoring rounding):

    {from CvCity.cpp L4,899}
    DistanceMaint = (Pop + 7) * 2.5 * Distance/DistanceScale * Building_m * WorldSize_m * Handicap_m

    where

    Distance = distance to closest goverment center (Palace, Forbidden Palace, Versailles)

    As usual, distance is calculated by treating diagonal steps as 1.5 steps (round down the final result).

    DistanceScale = (MapHeight + MapWidth) {from CvMap.cpp L925}

    Height and/or Width are halved if there is wrapping in that direction.

    Building_m = .5 if courthouse, 1 otherwise
    Worldsize_m: Duel=.50, Tiny=.60, Small=.70, Standard=.80, Large=.90, Huge=1
    Handicap_m: Settler=.45, Chieftain=.55, Warlord=.65, Noble=.75, Prince=.85, Monarch=.90, Emperor=.95, Immortal=1, Diety=1

    The not-so tidy formula with all the rounding should be (worth verifing):

    [ ([25*Distance*(Pop+7)/10] * Building_m * WorldSize_m * Handicap_m) / DistanceScale ]

    Here [...] means round down. I left out a few [...] to keep it clean - you also have to round down after applying each of these multiplicative factors: Building_m, WorldSize_m, Handicap_m (apply the factors from left to right)

    Big Curiosity (possible bug?): the '25' is actually the value of MAX_DISTANCE_CITY_MAINTENANCE in GlobalDefines.xml. Yet the 25 is just multiplied on; there is no min(25,distance) operation like you would think (See CvCity.cpp L4,912)


    Number of Cities Maintenance
    Here is a simplified formula (ignoring rounding and leaving out CityRank caclulations). 'N' is the number of cities you control:

    {from CvCity.cpp L4,940}
    CityMaint = N * (Pop + 17)/18 * WorldSize_m * Handicap_m + (1 for some cities, depending on cityrank)

    CityMaint = min(CityMaint, CitiesHandicap) * Building_m

    where

    Worldsize_m: Duel=.45, Tiny=.40, Small=.35, Standard=.30, Large=.25, Huge=.20
    Handicap_m: Settler=.40, Chieftain=.50, Warlord=.60, Noble=.70, Prince=.80, Monarch=.85, Emperor=.90, Immortal=.95, Diety=1
    CitiesHandicap: Settler=4, Chieftain=4, Warlord=5, Noble=5, Prince=6, Monarch=6, Emperor=7, Immortal=7, Diety=8
    Building_m = .5 if courthouse, 1 otherwise


    The full formula is (again apply the following multiplicative factors from left to right and round down after each multiplication: WorldSize_m, Handicap_m, Building_m):

    NumCitiesPercent = [100 * (Pop + 17)/18] * WorldSize_m * Handicap_m

    CityMaint = [N * NumCitiesPercent/100] + (1 if CityRank/N * 100 > 100 - (N * NumCitiesPercent) % 100)

    CityMaint = min(CityMaint, CitiesHandicap) * Building_m

    CityRank is 0 for the captial, 1 for the next closest city, and so forth (more precisely CityRank goes by distance first, game turn founded second, and unique city ID third.) '%' is the modulo operation, i.e. 11 % 3 = 2. Intuitively cities with higher city rank get the +1. Because of the modulo though it ends up being more of a fudge factor.
     
  10. KrikkitTwo

    KrikkitTwo Immortal

    Joined:
    Apr 3, 2004
    Messages:
    12,316
    Actually Not entirely
    if 'Pre courthouse' the # city maintenance is 4 or 5 depending on the fudge factor, they will both end up as 2... but if it is 5 or 6, they will end up as 2 or 3.


    But you are right it is a fudge factor to stop wierd massive jumps.

    Nice to know the actual formulas. (Mine were wrong because It seems to be the Actual Map and not the 'Map Size', and then there is the rounding effect)

    on a little side note, that means that if You have an empire that has run out of Foreign Trade routes that the empire size where the new Free Market and State Property are equal for Size 20 cities, fully developed, on a square unwrapped Huge map, at 50% Interest Deity Level, with optimum arrangement (cities evenly throughout circular areas around the 'Palaces'
    1/3 of the map area
    * Number of 'Palaces' (1-3)
    * ~4 if down to Settler level (inverse square of modifier)
    * ~4 if on a dual map (inverse square of modifier)
    *~2 if all Harbors
    /4+ if cities are missing Banks/Marketplaces and Grocers
    /4+ if cities are missing Courthouses.

    So an undeveloped, isolationist empire on a Noble difficulty, Standard map favors SP over FM at about 1/10 of Map area. Fully developed, FM is better than SP all the way up to the Domination Limit.

    (Population affects both Distance maintenance and Trade routes, so the population isn't much of an issue)

    a 'Watery' map removes some potentially profitable city sites, but allows for harbors.
     
  11. eg577

    eg577 Warlord

    Joined:
    Jun 1, 2002
    Messages:
    211
    Thanks for spotting that error (silly odd numbers...). I edited the post and also fixed some misc. things.

    I tested to see whether that '25' is really manifesting itself as a multiplication (as in maybe the code in the SDK had an uncorrected error). The SDK code agrees with the game code - the game really does multiply the 25 in there. In my tests I did uncover a very unusual find however: Land Mass Type and/or sea Level affect Maintenance.

    With a pangea map, low sea level, diety, standard map size my pop 1 city at a distance of 40 (18 up and 15 northwest, so there isn't a shorter route going across the world) had 11 distance maintenance, whereas if I change 'pangea' to 'balanced' and low sea level to medium it has only 9 maintenance. I repeated the experiment with a size 10 city at distance 10 (6 vs 4 maintenance) and a size 15 city at distance 15 (12 vs 9 maintenance). A guess would be that the .8 for standard size map gets bumped up to 1.0 for low sea level pangea maps (I haven't tested those two individually yet though).
     
  12. KrikkitTwo

    KrikkitTwo Immortal

    Joined:
    Apr 3, 2004
    Messages:
    12,316
    well the actual Sizes (Max ht+ Max Width) of a Pangea Standard map and a Balanced Standard map are different

    "Standard" is adjusted to get a particular amount of usable terrain/potential city spots or something like that) with whatever map type it gets.
     
  13. glundberg

    glundberg Chieftain

    Joined:
    Apr 4, 2006
    Messages:
    4
    This is a section from a larger project I'm working on. It should explain all the observations in earlier posts. Things really are not all that strange and there are no humps or plateaus. It's a simple linear function, albeit with a number of factors.
     

    Attached Files:

  14. bertram

    bertram Chieftain

    Joined:
    May 17, 2002
    Messages:
    45
    Location:
    Denmark
    map size
    Is there some kind factor/rule of thumb to figure out how much maintenance you pay on a small map compared to a standard map?

    What's the OCN each map type?

    my current game: I'm playing immortal on a small map, and have ca 9 cities, 700BC. And founding more cities cripples my economy.
     
  15. alatari

    alatari Chieftain

    Joined:
    Jun 27, 2006
    Messages:
    68
    Wow this has gotten to be a scientific study...

    Good work and good information.

    It's hard to calculate but founding a city to form up a border to keep out an ally is worth a great deal.

    After playing on a huge map (240 x 120) in what would be China and after founding my 33rd city I decided to come read up on city maintenance costs.
     
  16. NaZdReG

    NaZdReG Warmonger

    Joined:
    Jun 15, 2006
    Messages:
    553
    This is awesome research.

    I had an old diagram for visual aid of the "cheesy circle" otherwise known as ring city placement. it also is layed out in such a way to make sure that your surrounding cities get 13-14 tiles a piece to work, provided you make sure they only work the tiles specified. hopefully it will be useful to some

    NaZ
     
  17. Naastriil

    Naastriil Chieftain

    Joined:
    Jul 30, 2006
    Messages:
    31
    Location:
    Toronto, Ontario
    Wow. I never tought this thread would start a CIV science. :)
     
  18. CivScientist

    CivScientist Warlord

    Joined:
    Nov 7, 2005
    Messages:
    125
    In these formulas, does Pop represent the population of the individual city or the population of the entire empire?
     
  19. Samson

    Samson Deity

    Joined:
    Oct 24, 2003
    Messages:
    4,640
    Location:
    Cambridge
    The individual city
     
  20. ruff_hi

    ruff_hi Live 4ever! Or die trying

    Joined:
    Oct 24, 2005
    Messages:
    9,040
    Location:
    an Aussie in Boston
    This is interesting. I am planning a very large game on a huge map and I'm concerned about distance maintenance. I'm going to put together a little spreadsheet that will give me the optimal location for my Palace, Forbidden Palace and Versailles. I will post some results and a screen shot or two later.
     

Share This Page