Civic upkeep explained

You are welcome. It is exactly created with the early expansion in mind. This will at least take out one of the unknown about expansion cost. The other part of the equation would be figuring out the city upkeep cost.

Thanks for producing this article.
 
I've updated the article a bit.


-added a reference to the utility of Qitai. Thank you for sharing it Qitai!
-added the remark of grogs/colony about the starting research percentage at the higher difficulty levels with or without the organized trait.
-added a remark about the influence of inflation on civic upkeep cost in the late game
-added a rule of thumb for the lowest, highest and average upkeep costs of civics. It might be useful to estimate the profitability of a future city and the amount of cottages needed to make it profitable.

Thank you all for your remarks and suggestions.
 
Very interesting. Last week I bougth CivIV, now I'm trying it out. Such articles and spreadsheets help a lot. Thanks :goodjob:
 
Found an error in the spreadsheet where I input one of the figure wrongly.

Also, I have updated it so it is easier to use. Combo box and check box has been included so you can just pick the difficulty from the drop down list and check if you are organized and/or slavery. The numbers will then update automatically. For further calculation on other civics, you will still need to edit the first sheet directly to get the correct figures.

I have included # city cost to provide a summary of expected incremental cost of expansion due to civic and number of cities. I have also included a table for distance maintenance for reference so you can factor that into the cost of the next city. Using these combination, one can almost determine the cost of expansion exactly. I hope this helps. :)
 

Attachments

  • City and civic cost.zip
    18.9 KB · Views: 1,529
Qitai said:
Found an error in the spreadsheet where I input one of the figure wrongly.

Also, I have updated it so it is easier to use. Combo box and check box has been included so you can just pick the difficulty from the drop down list and check if you are organized and/or slavery. The numbers will then update automatically. For further calculation on other civics, you will still need to edit the first sheet directly to get the correct figures.

I have included # city cost to provide a summary of expected incremental cost of expansion due to civic and number of cities. I have also included a table for distance maintenance for reference so you can factor that into the cost of the next city. Using these combination, one can almost determine the cost of expansion exactly. I hope this helps. :)

View attachment 118559

I thought that there were still some rounding issues with the city distance and city number upkeep formulas. Maybe, I'm not quite up to date on these formulas. Not that this is a really big issue. It's good enough to get a very good estimate on the costs of founding a new city.

I updated the section in the article about your spreadsheet to refer to post 24 instead of 19.

Good work and thank you. :goodjob:
 
Yes, there is. But well, I think it is close enough for planning purpose. I just need to know if "the next city is worth the cost". Been using it to good effect so far ever since I got these formulas.

Anyway, even the distance formula is not exact, but it gives me a very good idea what might be the distance cost on planting that city, ignoring the increase in cost later as the city size grows.
 
Make some updates to my spreadsheet for 1.61 as well as new information on city city upkeep.

The civic cost seems to be different in 1.61 since I longer get the -2 cost for my first city (capital). Looked up the SDK and it looks like the formula has been changed to subtract an additional half times of the number of civics. So, I updated the spreadsheet.

I have also modified the formula for city # and distance upkeep according to the post by eg577 in the city upkeep thread.

Lastly, removed the slavery checkbox since slavery no longer give any cost saving compared to the initial civic.

View attachment City and civic cost.zip
 
I need a little help finding something. In the following formula (as given on the original post) there is number (made bold for this post) I cannot seem to change in the xml:

Government civics upkeep:
[D * [ O * ( [ P * (N-8) ] + [ C * (M-1) ] ) ] ]
Legal civics upkeep:
[D * [ O * ( [ P * (N-9) ] + [ C * M ] ) ] ]
Labor civics upkeep:
[D * [ O * ( [ P * (N-10) ] + [ C * (M+1) ] ) ] ]
Economy civics upkeep:
[D * [ O * ( [ P * (N-11) ] + [ C * (M+2) ] ) ] ]
Religion civics upkeep:
[D * [ O * ( [ P * (N-12) ] + [ C * (M+3) ] ) ] ]

I assumed it can only be modded in the SDK, so I went ahead and followed the procedure on how to get CodeBlocks and such. Now that I am in the CvGameCoreDll, I am having trouble finding where to go to change these values. Based on what I read elsewhere, I believe it is to be found in the CvGlobals.cpp, but I am not sure. Moreover, I may not even know what do once I find it (this is my first venture into any such programming language, and I know very little).

So, does anyone know where I have to go to adjust the numbers indicated above? And even further, what I have to do exactly?

Thanks :)
 
I need a little help finding something. In the following formula (as given on the original post) there is number (made bold for this post) I cannot seem to change in the xml:



I assumed it can only be modded in the SDK, so I went ahead and followed the procedure on how to get CodeBlocks and such. Now that I am in the CvGameCoreDll, I am having trouble finding where to go to change these values. Based on what I read elsewhere, I believe it is to be found in the CvGlobals.cpp, but I am not sure. Moreover, I may not even know what do once I find it (this is my first venture into any such programming language, and I know very little).

So, does anyone know where I have to go to adjust the numbers indicated above? And even further, what I have to do exactly?

Thanks :)

That's a very tough question for a first time poster on this site. So let me first say: welcome to civfanatics! :dance::band::dance:

When I wrote this article, the SDK wasn't available yet, so I got these formulas by testing ingame.

However, a few days ago, I also installed the SDK. I had to do that someday, better late than never. I'm not really familiar with reading this code, so it's hard to get into it. However, I think I have found where the formula is defined. I'm not exactly sure what you want to change, so maybe you don't even have to enter the SDK which I guess would be your preference.

You can find the formula in line 11412 and 11413 of the CvPlayer.cpp part of the CvGameCoreDll.

Spoiler :
iUpkeep += ((std::max(0, (getTotalPopulation() + GC.getDefineINT("UPKEEP_POPULATION_OFFSET") - GC.getCivicInfo(eCivic).getCivicOptionType())) * GC.getUpkeepInfo((UpkeepTypes)(GC.getCivicInfo(eCivic).getUpkeep())).getPopulationPercent()) / 100);
iUpkeep += ((std::max(0, (getNumCities() + GC.getDefineINT("UPKEEP_CITY_OFFSET") + GC.getCivicInfo(eCivic).getCivicOptionType() - (GC.getNumCivicOptionInfos() / 2))) * GC.getUpkeepInfo((UpkeepTypes)(GC.getCivicInfo(eCivic).getUpkeep())).getCityPercent()) / 100);


The first formula defines the population part of the civic upkeep cost and the second formula defines the city part of the civic upkeep cost.
The -8 value is defined by the variable UPKEEP_POPULATION_OFFSET which is defined in the GlobalDefines.xml file. It's a simple text edit to change that value into something else. (UPKEEP_CITY_OFFSET can also be found in this xml file and is normally set at -1.)
My guess is (but I'm not very familiar with reading this code) that the part GC.getCivicInfo(eCivic).getCivicOptionType())) gives a value between 1 and 5 depending on the civic category. So the government civics get a value of 1, the legal civics a value of 2, the labor civics a value of 3, etc. So that's why the formula changes depending on the civic category and the offset value decreases from -8 to -9 to -10 etc.

Note that there is a good reason that the formula is different for the various civic categories. If they would be the same for every category, then you would sometimes get sudden jumps in cost when the population would grow 1 point and no increase in costs at other moments when the population grows. Because of these slight differences between the formulas of the various civic categories, not all of them will increase at the same time. This results in a more continuous growth of civic costs instead of sudden jumps after long periods of a constant cost level.

If someone who is more familiar with reading this code can confirm that I read it right, then that might be nice. I'm not familiar with reading this code.
 
Thanks for the warm welcome and the fast reply :goodjob:

Moreover, thanks for the help! :D

You basically found what I needed; which was the simple old xml file. While I still might want to know how to adjust the values as given by the 'GC.getCivicInfo(eCivic).getCivicOptionType()))' part, I am content with setting the 'UPKEEP_POPULATION_OFFSET' to '0' and the 'UPKEEP_CITY_OFFSET' to '0'.

In your original post you mentioned why the offset numbers are important, and I agree with you. However, I am trying a universal one city challenge (i.e myself and the AI can only have one city) and the civic costs were practically non-existent. Combine this with no research costs (as I have changed the techs to be discoverable only by Great People, so there is a randomness to tech 'discovery' and techs actually feel like they are being discovered), and I was left with only unit costs to affect commerce (no maintenance costs either). Thus, commerce was pretty lame in this environment.

Once again, thanks for the help. I managed to find out how to do many other modifications by just researching these forums and analyzing and exploring the xml files, but I was lost on this one. Cheers :D
 
Thanks for the warm welcome and the fast reply :goodjob:

Moreover, thanks for the help! :D

You basically found what I needed; which was the simple old xml file. While I still might want to know how to adjust the values as given by the 'GC.getCivicInfo(eCivic).getCivicOptionType()))' part, I am content with setting the 'UPKEEP_POPULATION_OFFSET' to '0' and the 'UPKEEP_CITY_OFFSET' to '0'.

In your original post you mentioned why the offset numbers are important, and I agree with you. However, I am trying a universal one city challenge (i.e myself and the AI can only have one city) and the civic costs were practically non-existent. Combine this with no research costs (as I have changed the techs to be discoverable only by Great People, so there is a randomness to tech 'discovery' and techs actually feel like they are being discovered), and I was left with only unit costs to affect commerce (no maintenance costs either). Thus, commerce was pretty lame in this environment.

Once again, thanks for the help. I managed to find out how to do many other modifications by just researching these forums and analyzing and exploring the xml files, but I was lost on this one. Cheers :D

That is a very unusual scenario. It's a completely different game. Can the AI manage it or did you also change the AI?

Good luck modding. It can be fun all on its own.
 
I have not modded the AI; but I have monitored their tech progress by playing through some games and checking via the world builder. They seem to do perfectly well in that regard. I am uncertain, though, with how they are carrying on with the one city limit. I will keep at it though. I hope I am in not getting myself into something too deep (like having to rework the AI :eek:), but I am up for the task.

Thanks again.
 
are these formulas still correct for beyond the sword, warlords, or vanilla latest versions?
 
are these formulas still correct for beyond the sword, warlords, or vanilla latest versions?

i am also searching for that now. if any body finds any threat about this, please paste the link
i think BTS should have changed costs a little bit, I am sure. As economy is harder to balance.

but general ideas like the power of organized trait should have remained similarly.
 
are these formulas still correct for beyond the sword, warlords, or vanilla latest versions?

i am also searching for that now. if any body finds any threat about this, please paste the link
i think BTS should have changed costs a little bit, I am sure. As economy is harder to balance.

but general ideas like the power of organized trait should have remained similarly.

Sorry for the late reaction. I have been busy moving. There have been no changes to civic upkeep since vanilla civ4 version 1.52.
 
The formulas in the article is wrong the actual formulas are:

[D * [ O * ( MAX( 0 , [ P * (N-8) ] ) + MAX ( 0 , [ C * (M-3) ] ) ) ] ]
Legal civics upkeep:
[D * [ O * ( MAX( 0 , [ P * (N-9) ] ) + MAX ( 0 , [ C * (M-2) ] ) ) ] ]
Labor civics upkeep:
[D * [ O * ( MAX ( 0 , [ P * (N-10) ] ) + MAX ( 0 , [ C * (M-1) ] ) ) ] ]
Economy civics upkeep:
[D * [ O * ( MAX ( 0 , [ P * (N-11) ] ) + MAX ( 0 , [ C * (M) ] ) ) ] ]
Religion civics upkeep:
[D * [ O * ( MAX ( 0 , [ P * (N-12) ] ) + MAX ( 0 , [ C * (M+1) ] ) ) ] ]

Not sure when/if this changed with a patch or not though...
 
Thanks for the update. That would mean a small change to the formulas. That could have happened between then and now as the article is from 2005. I didn't recheck whether the formulas were still correct.

Note that in the days that the article was written, the SDK wasn't available yet, so the formulas were found by looking for formulas that fitted the actual results that were found ingame (through rigorous and extensive testing and comparing). While the formulas weren't extracted from the SDK, still the M-3, M-2, ... M+1 would still have been noticed when compared to the M-1, M, ... M+3 in the original post.
Non-negative values of the components of the civic upkeep were silently assumed, so no maximisation with 0 was put into the formula. It's mathematically more correct to add such maximisation.

Did you extract these formulas from the SDK?
 
Not putting the maximization in the formulas certainly caused me some headace over the last couple of days. These formulas are from the code. After finding that the formulas in the article didn't match up to ingame finding out the actual formulas became interesting.
 
The formulas in the article is wrong the actual formulas are:

[D * [ O * ( MAX( 0 , [ P * (N-8) ] ) + MAX ( 0 , [ C * (M-3) ] ) ) ] ]
Legal civics upkeep:
[D * [ O * ( MAX( 0 , [ P * (N-9) ] ) + MAX ( 0 , [ C * (M-2) ] ) ) ] ]
Labor civics upkeep:
[D * [ O * ( MAX ( 0 , [ P * (N-10) ] ) + MAX ( 0 , [ C * (M-1) ] ) ) ] ]
Economy civics upkeep:
[D * [ O * ( MAX ( 0 , [ P * (N-11) ] ) + MAX ( 0 , [ C * (M) ] ) ) ] ]
Religion civics upkeep:
[D * [ O * ( MAX ( 0 , [ P * (N-12) ] ) + MAX ( 0 , [ C * (M+1) ] ) ) ] ]

Not sure when/if this changed with a patch or not though...

Perhaps someone should update the article. this information is really good and should not be hidden in the forum.
 
Top Bottom