Formula analysis

Acken

Deity
Joined
Sep 13, 2013
Messages
5,902
Location
QC, Canada
Additional information regarding growth.
I found that the growth is controlled by the constructibles XML file.

Antiquity has the following values: Flat = 30, Scalar = 3, Exponent = 33.
After a lot of trial and error, the formula was reversed engineered to:
Food cost = Flat + Scalar * x + x ^ (Exponent / 10). Rounded down.
where x is the number of growth event you had so far (different to the city pop count which includes district buildings).
It's pretty easy to see that the right hand part make this grow super high. This suggests that it was intentionally put that way to throttle growth per age.
As a comparison, the values for Exploration are
Flat = 20, Scalar = 20, Exponent = 30
These two curves get equal around pop 5, meaning you require less food in exploration after pop 5.
Similarly the modern age curve is Flat = 20, scalar = 40, exponent = 27. You will require less food in modern after pop 7.
 
Good find! There should be a formula thread for mechanics like this that aren't transparent in-game.

Moderator Action: Done --NZ
 
Last edited by a moderator:
You guys like more formulas ?

Happiness cost for celebrations:
Antiquity
GOLDEN_AGE_HAPPINESS_CURVE_A -2.53
GOLDEN_AGE_HAPPINESS_CURVE_B 125
GOLDEN_AGE_HAPPINESS_CURVE_C -8.19
GOLDEN_AGE_HAPPINESS_CURVE_D 85.4
Exploration
GOLDEN_AGE_HAPPINESS_CURVE_A -10.12
GOLDEN_AGE_HAPPINESS_CURVE_B 500
GOLDEN_AGE_HAPPINESS_CURVE_C -32.76
GOLDEN_AGE_HAPPINESS_CURVE_D 341.6
Modern
GOLDEN_AGE_HAPPINESS_CURVE_A -16.87
GOLDEN_AGE_HAPPINESS_CURVE_B 833.33
GOLDEN_AGE_HAPPINESS_CURVE_C -54.6
GOLDEN_AGE_HAPPINESS_CURVE_D 569.33

This time Firaxis is nice enough to give us a detail of the formula in comments of the gameplay-systems.xml:
ax^3 + bx^2 + cx + d where x is the count of the future celebration.
Plugging it in this givesthe following curves:
I haven't yet checked if always exact but it at least matches the 40 turns necessary when starting the game at +5 happiness.
(Third column should be modern)

1739465666254.png
 
You guys like more formulas ?

Happiness cost for celebrations:
Antiquity
GOLDEN_AGE_HAPPINESS_CURVE_A -2.53
GOLDEN_AGE_HAPPINESS_CURVE_B 125
GOLDEN_AGE_HAPPINESS_CURVE_C -8.19
GOLDEN_AGE_HAPPINESS_CURVE_D 85.4
Exploration
GOLDEN_AGE_HAPPINESS_CURVE_A -10.12
GOLDEN_AGE_HAPPINESS_CURVE_B 500
GOLDEN_AGE_HAPPINESS_CURVE_C -32.76
GOLDEN_AGE_HAPPINESS_CURVE_D 341.6
Modern
GOLDEN_AGE_HAPPINESS_CURVE_A -16.87
GOLDEN_AGE_HAPPINESS_CURVE_B 833.33
GOLDEN_AGE_HAPPINESS_CURVE_C -54.6
GOLDEN_AGE_HAPPINESS_CURVE_D 569.33

This time Firaxis is nice enough to give us a detail of the formula in comments of the gameplay-systems.xml:
ax^3 + bx^2 + cx + d where x is the count of the future celebration.
Plugging it in this givesthe following curves:
I haven't yet checked if always exact but it at least matches the 40 turns necessary when starting the game at +5 happiness.
(Third column should be modern)

View attachment 719524
Which means that if you get to ~30th Celebration, then next one will be cheaper (and ~ the 50th one would be Free)
 
Which means that if you get to ~30th Celebration, then next one will be cheaper (and ~ the 50th one would be Free)
Good point but there's actually a value somewhere called GOLDEN_AGE_PLATEAU_COUNT 7 which probably means that it caps at the 7th
 
How would parameters that precise even be determined? If there is a plateau parameter then they're using 5 parameters to calculate 7 different values, why not just store the values directly?
 
How would parameters that precise even be determined? If there is a plateau parameter then they're using 5 parameters to calculate 7 different values, why not just store the values directly?
They probably got the values they wanted to achieve first and applied a polynomial regression to it. Who knows. Problem with saving 7 values is that it's a bit cumbersome to use and mod. I just dont know why they dont just reuse the pop food formula with different values.
 
Last edited:
Additional information regarding growth.
So all of that is for the base number right? How does bonus to growth affect the actual amount of food required to grow? It used to be the case that the growth bonus would simply reduce the amount of food required (so at 100% growth you were in permanent "baby boom" mode getting a new pop every turn - and above 100% food requirement would go negative and you would never grow again :rotfl: ).
Firaxis fixed the negative food in one of the first patches but it seems like they also changed the way growth bonus affects the amount of food require. I'm playing Khmer RN with Charkravarti civic unlocked (+50% in capital), Pen & Brush memento (+25% from my 5 specialists), Hanging Garden (+10%), Expansionist T2 (+10%) and a Bath (+10%) so i'm sitting at 105% growth but my capital isn't growing every turn.
Does bonus to growth simply act like +% food now or is it different? Did anyone test that?
 
So all of that is for the base number right? How does bonus to growth affect the actual amount of food required to grow? It used to be the case that the growth bonus would simply reduce the amount of food required (so at 100% growth you were in permanent "baby boom" mode getting a new pop every turn - and above 100% food requirement would go negative and you would never grow again :rotfl: ).
Firaxis fixed the negative food in one of the first patches but it seems like they also changed the way growth bonus affects the amount of food require. I'm playing Khmer RN with Charkravarti civic unlocked (+50% in capital), Pen & Brush memento (+25% from my 5 specialists), Hanging Garden (+10%), Expansionist T2 (+10%) and a Bath (+10%) so i'm sitting at 105% growth but my capital isn't growing every turn.
Does bonus to growth simply act like +% food now or is it different? Did anyone test that?
It was recently changed yes. It is now like the buying reductions.
So the new cost will be divided by 1+growth. So if you play Confucius, the first pop costs 30 (x=0) gets reduced to 30/1.25 = 24. Getting 100% should result in being divided by 2.
In essence now a +X% growth is now equivalent to +X% food but being on a different modifier (so that +25% food and +25% growth should be a bit better than +50% food)
 
It was recently changed yes. It is now like the buying reductions.
So the new cost will be divided by 1+growth. So if you play Confucius, the first pop costs 30 (x=0) gets reduced to 30/1.25 = 24. Getting 100% should result in being divided by 2.
In essence now a +X% growth is now equivalent to +X% food but being on a different modifier (so that +25% food and +25% growth should be a bit better than +50% food)
Apparently that doesn't apply for the Factory Fish...(it seems 20 fish will trigger the insta pop grow)
 
Apparently that doesn't apply for the Factory Fish...(it seems 20 fish will trigger the insta pop grow)
🤔 How the hell is this game coded.
The fish uses a different modifier EFFECT_CITY_ADJUST_GROWTH_PER_RESOURCE
instead of
EFFECT_CITY_ADJUST_GROWTH
like Hanging gardens and Confucius
so it could be the formula was changed only for EFFECT_CITY_ADJUST_GROWTH and not the other ?!?
 
Additional information regarding growth.
I found that the growth is controlled by the constructibles XML file.

Antiquity has the following values: Flat = 30, Scalar = 3, Exponent = 33.
After a lot of trial and error, the formula was reversed engineered to:
Food cost = Flat + Scalar * x + x ^ (Exponent / 10). Rounded down.
where x is the number of growth event you had so far (different to the city pop count which includes district buildings).
It's pretty easy to see that the right hand part make this grow super high. This suggests that it was intentionally put that way to throttle growth per age.
As a comparison, the values for Exploration are
Flat = 20, Scalar = 20, Exponent = 30
These two curves get equal around pop 5, meaning you require less food in exploration after pop 5.
Similarly the modern age curve is Flat = 20, scalar = 40, exponent = 27. You will require less food in modern after pop 7.
Why does the population jump very quickly at the start of the game regardless of the Growing Formula? Is this a bug?
 
Why does the population jump very quickly at the start of the game regardless of the Growing Formula? Is this a bug?
You mean the free pop you get on turn 3 in the capital ? It's a feature. It's defined somewhere in the files along with the 1 turn scout or warrior on turn 1. A bit similar to how you get a free pop when making new settlements.
 
You mean the free pop you get on turn 3 in the capital ? It's a feature. It's defined somewhere in the files along with the 1 turn scout or warrior on turn 1. A bit similar to how you get a free pop when making new settlements.
Yes exact what I mean. Ok, good to know. Thank you!

Do you plan to make new videos about Civ7?
 
Good point but there's actually a value somewhere called GOLDEN_AGE_PLATEAU_COUNT 7 which probably means that it caps at the 7th
Apparently that might be different at different Ages, do you have the Exploration and Modern values for it?
 
It's likely the same since nothing in the files changes that value (contrary to the curve parameters). Do you have some evidence of the contrary ?
No, just thought it might be in the same spot as the other parameters (since they all adjust based on age).,... so that means the max is ~5k Antiquity, 21k Exploration and 35k Modern.
 
Town to city conversion gold cost
I couldn't find this in the data .xml files, so just derived from in-game behavior. It doesn't seem to vary by age.

Gold cost = 400 + 300*c - 50*p
c = # of cities currently (including capital), p = population (urban + rural) of town to convert.

As stated in the Civilopedia, captured settlements cost double to convert, and conversion cost is capped at a maximum of 1000 gold and a minimum of 200 gold. Civilopedia also says some modifiers can reduce the cost below 200, but it seems the 1000 is a hard maximum.

Examples:
- It costs 600 gold to convert a new town (pop 2) with only 1 city (capital). It needs to be size 10 to reach the minimum cost of 200 gold.
- For every additional city, it takes an additional 6 pop. to reach the minimum cost (so 10, 16, 22, 28, etc.).
- The maximum cost (1000 gold) applies to towns of population 6 and lower when you have 3 cities, pop 12 and lower with 4 cities, etc. (going up by 6 each time, again).

Some implications:
- If you convert many towns at once (e.g. beginning of new age), you may save gold by first converting the ones with the smallest population, and finishing with the higher pop ones.
- Because urban population counts, each building can save 50 gold at the time of conversion if you're in the range between the min and max cost. So even if you're not Augustus, there is a kind of discount with buying a building in the town vs. buying it after converting.
 
Back
Top Bottom