Formula analysis

Acken

Deity
Joined
Sep 13, 2013
Messages
5,840
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?
 
Back
Top Bottom