What is the Formula for Unit Maintenance in Civilization V?
Question says it all. I know vaguely what is going on, but want something specific.
Edit: Here's some "interesting" values in the GlobalDefines.xml file. No idea at this point what they mean.
- INITIAL_GOLD_PER_UNIT_TIMES_100 50
- INITIAL_FREE_OUTSIDE_UNITS 3
- INITIAL_OUTSIDE_UNIT_GOLD_PERCENT 0
- UNIT_MAINTENANCE_GAME_MULTIPLIER 8
- UNIT_MAINTENANCE_GAME_EXPONENT_DIVISOR 7
Solution 1:
Short answer: Maintenance is a function of the turn and the number of units. The function resembles a third degree polynomial for both variables.
Advice for keeping maintenance low: Don't keep a lot of units, as each new unit costs more than the last. If you are going to have a lot of units, have them early in the game, where the costs are still bearable.
Analysis: I tried to edit the global settings as bwarner suggested. Here is what I found:
Turn Units MULTI DIVISOR Maintenance cost
46 10 0 0 0
46 10 1 1 6
46 10 20 0 0
46 10 20 1 18
46 10 20 2 16
46 10 20 3 15
46 10 20 20 14
46 10 100 1 73
46 10 10000 1 10005
46 10 100000 1 123533
46 10 1000000 1 1526640
46 10 1000 1 818
47 10 1000 1 847
48 10 1000 1 878
49 10 1000 1 909
50 10 1000 1 941
51 10 1000 1 973
52 10 1000 1 1007
53 10 1000 1 1041
54 10 1000 1 1076
46 10 10000 1 10005
47 10 10000 1 10417
48 10 10000 1 10842
49 10 10000 1 11280
50 10 10000 1 11731
51 10 10000 1 12195
52 10 10000 1 12674
53 10 10000 1 13167
54 10 10000 1 13675
55 10 10000 1 14198
56 10 10000 1 14737
It takes some time to reload the game between trials. Apparently setting either of these settings to zero reduces the cost to zero. We can also conclude that raising the multiplier increases cost, and raising the divisor lowers it.
While this is obviously not an answer, I posted it anyway as I don't have enough reputation to add a comment. Maybe if we work together on solving this problem we might discover the answer. By the way I did some regression analysis on the numbers, but I wasn't able to find anything useful.
EDIT: I tried to change the INITIAL_GOLD_PER_UNIT_TIMES_100 value as well, but that didn't seem to have any effect on maintenance cost.
EDIT 14th of oct: I've updated with some more data that seems to shed a little more light on the issue. Increasing the multiplier to a large number has two advantages:
- It clears the shroud of rounding (maintenance can apparently only be an integer).
- It puts focus on the particular product of the equation that is supposedly multiplied
A couple of observations can be made about the formula:
- Each spin of the turn counter increases maintenance cost
- Increasing the multiplier increases the cost by more than a proportional amount
- Each spin of the turn counter increases maintenance cost more than the last, in absolute terms
- Each spin of the turn counter increases maintenance cost less than the last in relative terms
- Polynomials share those two last properties
Feel free to chime in with any considerations you might have.
Here is some more data:
- Two units, 1000 multiplier, 1 divisor, turn 6 - 100
- 2-20 units, 1000 multiplier, 1 divisor, turn 133-163
EDIT 22nd of October: The patch that has come out changes the formula. I will take a further look and then report back. What is obvious already is that the only-every-second-unit-counts rule is gone. I have updated the advice in the top to reflect that.
Solution 2:
While I am not about to count what I say as an answer to my question, I have been trying to figure out the answer on my own. I have been playing a Prince difficulty game at Standard speed on a Standard size map. Or, the most vanilla game type possible. Every so often I would record the number of units I had, the turn number, and my current unit maintenance. This created a data set for me. Now, it was obvious just by deleting units that maintenance was linear with number of (even) units. I plugged this data into various regression analysis crunchers, i.e. looking at different types of equations to see which one was the best fit for the data.
I thought it would be exponential, but linear appeared to be a better fit. Then I tried parabolic, and got the best fit yet. The equation below gave me maintenance to within one gold piece for all my data points.
2 × [Number of Units, if odd subtract 1] × [.00000619*T² + 0.00404478*T + 0.15814034]
R^2 was .999. "T" obviously stands for current Turn. Unfortunately, I am only on turn 384, so I have to see if this parabolic equation holds for the remainder of the game. If anyone can volunteer more data (Prince:Standard:Standard settings only right now), I can easily copy it into my data set and arrive at a more precise understanding. Just list Units, Turn, and Unit Maintenance.
If this equation is right, then I could see why Firaxis did not bother to publish it. However, I am stunned that Firaxis thought a Parabola was a good way to determine unit maintenance, especially when economies have no such way to grow in tandem.
Edit: Hmmm... I am going to withdraw this formula for now. It failed to predict upkeep costs as I finished that game. Certainly, throwing in the new points resulted in slightly different Parabolic equation still with an R2 of .999, but as finicky as this type of equation is, I need more data to determine if unit maintenance is indeed parabolic or something else entirely.
Solution 3:
I've collected some data and used the program Eureqa to find possible equations for the maintenance cost. I did not modify any XML values, I'm using vanilla Civ5 here.
Im using u
for the number of units, t
for the turn number and c
for the maintenance cost.
Unit scaling
The dependence of the maintenance cost on the number of units (at turn 499) can be fitted to the equation
f(u) = 5.56 * u^1.14
always rounded down. I've calculated this from data at turn 499 with data from 0 to 452 units, only using even numbers of units.
Turn scaling
The dependence on the turn number (with 100 units) can be fitted to the exponential equation
f(t) = 1.5011171*exp(5.1752067 + 0.0031669112*t) - 214.9911
This is based on data with 100 units for turn 0 to 500.
I could not find a satisfactory equation that combines these two aspects of unit maintenance.
The unit supply limit does not have any effect on maintenance costs, it just reduces the production rate of your cities by 10% per unit over the limit up to a maximum reduction of 70%.
Map size and difficulty could also have an effect on maintenance, this still has to be determined.
I've put the data I collected into a Google Docs Spreadsheet (only valid for 24 hours, maybe someone can put it into a more permanent home).
Solution 4:
The nearest answer I could find was this: http://forums.civfanatics.com/showthread.php?p=9666379
It seems to indicate it is proportionate to pairs of units, also that it scales with difficulty and time (due to inflation).
Solution 5:
At turn 285, I erased all my units one at a time. I had a reduction in maintenance costs of 8 or 9 golds every other turn. So it confirms what you say.
I'll try again around turn 400.