Solving the mystery: Unit Maintenance

Status
Not open for further replies.

Xger

Prince
Joined
Mar 22, 2010
Messages
510
Location
Denver
I am currently in the process of trying to figure out how unit maintenance works. For now I created a map/scenario built to help uncover the workings of it.

Interesting things so far:
  • Era you are in has no effect. At least units built in one era do not increase cost based solely on moving to a new era, or discovering a new tech.
  • The type of unit does not matter (civilian versus military versus naval versus great person)
  • In the beginning of the game, maintenance seems deliberately lower.
  • The 'age' of a unit seems irrelevant. It seems more likely to be tied to number of turns existed.
  • It does not scale off of GPT or population. Number of cities has yet to be tested.
  • Difficulty level makes a difference. It appears only levels below prince have adjusted levels of maintenance. Prince and Deity had the same cost at least initially.

I am posting at this during the test stage simply to get input on things to test, oddities that people have noticed and things like that. I will update as I get more done.

Interesting side note: Militaristic City States at Ally status do not give a unit every 17 turns. So far with a small sample size, the average is 17, but it varies from 16 to 18 turns.
 
My guess is that game turn (and game speed) is the big determining factor.

The other thing I'd like to know is if supply cap matters at all; is it just number of units, or is it number of units relative to supply cap?
 
My guess is that game turn (and game speed) is the big determining factor.

The other thing I'd like to know is if supply cap matters at all; is it just number of units, or is it number of units relative to supply cap?

Some quick tests showed no change initially based on game speed.
 
Well if the game turn factor works the way inflation did in Civ 4, then there is 0 inflation for the first few (hundred possibly) turns, and then a steady increase in inflation.
 
I heard it mentioned on here that units should be deleted in pairs, as the game counts them that way. I swear ive deleted a worker and had no reduction in unit costs, while the next one deleted has knocked 7 or so off. Though it doesn't seem to be happening now I'm in the industrial era. Have you seen any sign of this?
 
What I don't get is a lot of the game features appear to give simple numbers so players don't have to do hard math to get by. For example, unhappiness per-city, City State bonuses, unit HP, etc.

But then we have the most OBSCURE calculation by far in the form of unit maintenance. I can't for the life of me figure it out. Why when I delete a worker I gain 7 gold? It makes no sense.
 
The XML for the game has a few entries for unit maintenance.

One is a "gold weight per unit divided by 100" which is set to 50, or 50%. This might explain why only every other unit increases maintenance, due to some rounding error.

There is also a "unit maintenance exponent" which is 1.01.

My guess would be the formula is going to be something like

units * 0.5 * constant * ( turns * some fractional constant ^ 1.01)

Not exactly that formula, but the gist of it I'm guessing, where every second unit increases maintenance by an amount that grows as the turn count increases (aka. inflation).
 
Here is a great idea from Xger. Like many people here, I'm still left totally wondering about how unit maintenance is calculated: on turn I get +7 gpt, the next one after one new unit I'm totally crippled at -20 gpt without having that much of an explanation. I have nothing against having to balance my budget as long as I can figure out how to do it and that comes first by exactly knowing how the maintenance costs works.
 
The XML for the game has a few entries for unit maintenance.

One is a "gold weight per unit divided by 100" which is set to 50, or 50%. This might explain why only every other unit increases maintenance, due to some rounding error.

There is also a "unit maintenance exponent" which is 1.01.

My guess would be the formula is going to be something like

units * 0.5 * constant * ( turns * some fractional constant ^ 1.01)

Not exactly that formula, but the gist of it I'm guessing, where every second unit increases maintenance by an amount that grows as the turn count increases (aka. inflation).

Well someone also found "inflation offset" so most likely

round off (units * 0.5) * constant * [max((turns - offset),0] ^ 1.01
 
Not exactly that formula, but the gist of it I'm guessing, where every second unit increases maintenance by an amount that grows as the turn count increases (aka. inflation).

Not only does cost per unit seem to rise as the turn counter in incremented, but cost per unit also seems to rise within the same turn depending on how many units you have. For example, in my test game having an army with two units is cheaper per unit than having an army with eighteen units on the same game turn.

In the XML data, I see an inflation percent and an Inflation offset that's related to game speed, and then another inflation percent related to difficulty level. In addition, the following possibly related values are stashed away in the set of defines:
UNIT_MAINTENANCE_GAME_MULTIPLIER: 8
UNIT_MAINTENANCE_GAME_EXPONENT_DIVISOR: 7
INITIAL_GOLD_PER_UNIT_TIMES_100: 50
 
I heard it mentioned on here that units should be deleted in pairs, as the game counts them that way. I swear ive deleted a worker and had no reduction in unit costs, while the next one deleted has knocked 7 or so off. Though it doesn't seem to be happening now I'm in the industrial era. Have you seen any sign of this?

Yes. I think it was in CIV4 too. It's a very annoying mechanic to play with and I can't imagine why they've persisted with it.
 
The XML for the game has a few entries for unit maintenance.

One is a "gold weight per unit divided by 100" which is set to 50, or 50%. This might explain why only every other unit increases maintenance, due to some rounding error.

There is also a "unit maintenance exponent" which is 1.01.

My guess would be the formula is going to be something like

units * 0.5 * constant * ( turns * some fractional constant ^ 1.01)

Not exactly that formula, but the gist of it I'm guessing, where every second unit increases maintenance by an amount that grows as the turn count increases (aka. inflation).

I bet they did something like you did, only they accidently did (units/2) where units was an integer. In programming this would result in only every other one resulting in an increase.
 
I bet they did something like you did, only they accidently did (units/2) where units was an integer. In programming this would result in only every other one resulting in an increase.

The data suggests that this is exactly what's happening. Given that this is one of the first errors taught in any computer science class, I am very dissatisfied.
 
"Number of turns existed" - units who live long cost more or less?
 
I bet they did something like you did, only they accidently did (units/2) where units was an integer. In programming this would result in only every other one resulting in an increase.

I'd put money on it that this is what happened. :lol:
 
The formula so far need to be improved. It may not be a simple multiplication of integers, because I often have a prime number unit maintenance.
 
I'd put money on it that this is what happened. :lol:

Honestly, it seems highly unlikely that a programming error is to blame. Given the nature of how it seems to work, I wouldn't be surprised if they had simply decided maintenance was too high, and halved it by making only every other unit count. Maybe not the prettiest solution, but it would likely be considerably easier than redoing the whole formula.
 
It would be far better for the 1/2 to happen at the end of the formula.

It would also be far better if unit costs were like buildings.. different units cost different amounts, and that cost was constant throughout the game. (maybe *2 if obsolete or something like that)
 
Dammit! Why someone from firaxis can't just post here and tell us already!? Is it so much to ask?
 
Status
Not open for further replies.
Top Bottom