(*) 21.12.2020: Revision 1, major changes, please read the posting again. See end of thread for Revisions.
Introduction
I'm trying to describe some fundemantal HOI4 mechanics mathematically. The thread on Civilian Factories (CIVs) is the first in a series, more threads will follow.
My goal is to describe game mechanics as accurate as possible, while also trying not to get stuck in unimportant details.
My benchmark are testruns. Running the game should give the same results as the math. (In a reasonable precision)
That means, if you can provide a testrun, that doesn't fit with the math, please tell me.
Derviation of the CIV-Formula
Let's describe the number of owned CIVs at the time t with the function c(t).
We know that 1 civilian factory has a construction output of 5 per day modified by production bonuses and infrastructure.
So we define the first important constant called CPD.
CPD stands for CIVs per day and is the amount of CIVs that 1 CIV can produce in 1 day.
CPD is the CIV construction speed of 1 CIV.
Infra stands for the infrastructure modifier in % (0% for Level 0 Infrastructure and 100% for Level 10 Infrastructure)
Bonus stands for the sum of production bonuses in %. (From Trade law, Construction research, Advisors and so on...)
5 is the construction output of 1 CIV
10800 is the production cost of 1 CIV
Defining this as a constant (invariable for the time t) might seem wrong, as infrastructure and production bonuses are not constant over the game. But it's not wrong because I chose to derive a formula for the timespan where CPD is constant. The game consists of timespans where CPD is constant in a row. More about this in the Conclusions at the end of the thread.
So with the CIV construction speed of 1 CIV defined we can calculate the overall CIV construction speed.
We call the overall CIV construction speed "c-dot"(t), the derivate of c(t) by the time t.
It's the rate by which the number of owned CIVs changes:
To calculate it we have to consider the number of CIVs that are available for construction.
We call them c_av(t):
c_av(t) is the number of CIVs available for construction
c(t) is the number of owned CIVs
c_in is the number of "incoming" CIVs e.g. from trade, licenses, puppets or occupation
c_out is the number of "outgoing" CIVs e.g. for trade, licenses or other constructions
CG is the Consumer Goods Ratio
m_0 is the number of Military factories (MILs) at the start point of the calculation
Note that c_in is reduced with CG and c_out is just substracted. That means with even trade you have less CIVs than with no trade.
Assumptions needed here:
We have to consider that c_av(t) is a number with decimal places and incomplete CIVs can't contribute to construction.
CIVs are organized in production lines with 15CIVs per line. So the number of production lines is about c_av(t) / 15
Each production line progresses in most cases with constant speed. That means the average progress of a production line over time is about 50%.
c_av(t) includes the unfinished CIVs, so our estimated correction is to substract 0.5 CIVs per line:
To find c_av_dot(t) we have to derive the equation (3) by the time t. Only c(t) is dependent on the time, so we get:
Now we bring c_dot(t) from equation (5) into equation (6) and get:
The equation (7) is a differential equation, because it sets c_av(t) and c_av_dot(t) into relation. It can be solved to get a formula for c_av(t).
Solving the differential equation
Equation (7) is a very basic differential equation for growth of the type:
with the well known solution:
We get:
Now we use the start conditions to find const. We call c_av_0 the number of CIVs available for consturction at t = 0. (Remark: t = 0 is not necessary the game start date.)
We found our result:
The CIV-Formula
Where:
c_av(t) is the number of CIVs available for construction at the time t
c_av,0 is the number of CIVs available for construction at the time 0
CG the consumer goods ratio (and constant as long as the formula is valid)
CPD the CIV construction speed of 1 CIV (and constant as long as the formula is valid)
The relation between c_av(t) (CIVs available for construction) and c(t) (CIVs owned) is: (Equation 3 reordered)
Or if we want to calculate c(t) (the number of CIVs owned) we can write (13) as:
Equation (12) is a formula of exponential growth, as everybody knows... (CIVs build CIVs, that CIVs build more CIVs faster, ...)
But the growth is slow, due to the factors being small. Here's an example:
Example
Soviet Union at 1936 start.
c_0 = 44 CIVs
m_0 = 32 MILs
CG = 20% (console cheat instant war economy)
c_in = 0 (No CIVs incoming for trade, licenses, Puppets or occupation
c_out = 0 (No CIVs used for trade or buying licenses, or other constructions)
CPD = 0.0009 (Level 5 Infrastructure, 30% Construction Bonus [Export Focus, Construction1, Captain of Industry] )
Run it for 1000 days:
Ingame Testrun gives 79 owned CIVs, 57 CIVs available for construction and 2.09 incomplete CIVs in construction
Formula gives 80.36 owned CIVs and 57.89 available CIVs
The number of CIVs after 1000 days is 80. It takes over 3 years (1144 days) to double the number of CIVs.
Look at Graph:
(The dotted line "Linear (CIVs)" is a linear regression line from excel.)
(In a real game you would research more levels of construction, get new CIVs by focus, trade, conquer new CIVs and so on... This example is here to show only the exponential nature of building CIVs and that the effect is small.)
Implications and Conlusions
Decisive factors for rapid CIV growth
Let's look at equation (3) again:
(3)
To have more CIVs available for construction you want to:
(12)
In an exponential term of the form e^(k*t) the factor k determines the speed of the growth. We want a large k.
With the use of (1) we can write k as:
(15)
We can increase k and thus the construction speed of CIVs by:
Edits:
Revision1: (21.12.2020)
Introduction
I'm trying to describe some fundemantal HOI4 mechanics mathematically. The thread on Civilian Factories (CIVs) is the first in a series, more threads will follow.
My goal is to describe game mechanics as accurate as possible, while also trying not to get stuck in unimportant details.
My benchmark are testruns. Running the game should give the same results as the math. (In a reasonable precision)
That means, if you can provide a testrun, that doesn't fit with the math, please tell me.
Derviation of the CIV-Formula
Let's describe the number of owned CIVs at the time t with the function c(t).
We know that 1 civilian factory has a construction output of 5 per day modified by production bonuses and infrastructure.
So we define the first important constant called CPD.
CPD stands for CIVs per day and is the amount of CIVs that 1 CIV can produce in 1 day.
CPD is the CIV construction speed of 1 CIV.
(1)
Infra stands for the infrastructure modifier in % (0% for Level 0 Infrastructure and 100% for Level 10 Infrastructure)
Bonus stands for the sum of production bonuses in %. (From Trade law, Construction research, Advisors and so on...)
5 is the construction output of 1 CIV
10800 is the production cost of 1 CIV
Defining this as a constant (invariable for the time t) might seem wrong, as infrastructure and production bonuses are not constant over the game. But it's not wrong because I chose to derive a formula for the timespan where CPD is constant. The game consists of timespans where CPD is constant in a row. More about this in the Conclusions at the end of the thread.
So with the CIV construction speed of 1 CIV defined we can calculate the overall CIV construction speed.
We call the overall CIV construction speed "c-dot"(t), the derivate of c(t) by the time t.
It's the rate by which the number of owned CIVs changes:
(2)
To calculate it we have to consider the number of CIVs that are available for construction.
We call them c_av(t):
(3)
c_av(t) is the number of CIVs available for construction
c(t) is the number of owned CIVs
c_in is the number of "incoming" CIVs e.g. from trade, licenses, puppets or occupation
c_out is the number of "outgoing" CIVs e.g. for trade, licenses or other constructions
CG is the Consumer Goods Ratio
m_0 is the number of Military factories (MILs) at the start point of the calculation
Note that c_in is reduced with CG and c_out is just substracted. That means with even trade you have less CIVs than with no trade.
Assumptions needed here:
- The number of MILs is constant over the time where the formula is valid. We are not constructing MILs and CIVs at the same time. More about constructing MILs and MILs and CIVs at the same time in another thread.
- Cosumer Goods ratio is constant. Same as with the construction bonuses. The formula is valid for the timespan where it is constant. More about this in the Conclusions at the end of the thread.
- CIVs from trade, to trade, from licenses, to licenses, from puppets, from occupations and for other constructions are constant. That's an issue because in a real game these will not be constant. I have no good idea yet how to bring trade into this, because it can be quite random. If you have a good idea how to model CIVs from trade, please tell me.
(4)
We have to consider that c_av(t) is a number with decimal places and incomplete CIVs can't contribute to construction.
CIVs are organized in production lines with 15CIVs per line. So the number of production lines is about c_av(t) / 15
Each production line progresses in most cases with constant speed. That means the average progress of a production line over time is about 50%.
c_av(t) includes the unfinished CIVs, so our estimated correction is to substract 0.5 CIVs per line:
(5)
To find c_av_dot(t) we have to derive the equation (3) by the time t. Only c(t) is dependent on the time, so we get:
(6)
Now we bring c_dot(t) from equation (5) into equation (6) and get:
(7)
The equation (7) is a differential equation, because it sets c_av(t) and c_av_dot(t) into relation. It can be solved to get a formula for c_av(t).
Solving the differential equation
Equation (7) is a very basic differential equation for growth of the type:
(8)
with the well known solution:
(9)
We get:
(10)
Now we use the start conditions to find const. We call c_av_0 the number of CIVs available for consturction at t = 0. (Remark: t = 0 is not necessary the game start date.)
(11)
We found our result:
The CIV-Formula
(12)
Where:
c_av(t) is the number of CIVs available for construction at the time t
c_av,0 is the number of CIVs available for construction at the time 0
CG the consumer goods ratio (and constant as long as the formula is valid)
CPD the CIV construction speed of 1 CIV (and constant as long as the formula is valid)
The relation between c_av(t) (CIVs available for construction) and c(t) (CIVs owned) is: (Equation 3 reordered)
(13)
Or if we want to calculate c(t) (the number of CIVs owned) we can write (13) as:
(14)
Equation (12) is a formula of exponential growth, as everybody knows... (CIVs build CIVs, that CIVs build more CIVs faster, ...)
But the growth is slow, due to the factors being small. Here's an example:
Example
Soviet Union at 1936 start.
c_0 = 44 CIVs
m_0 = 32 MILs
CG = 20% (console cheat instant war economy)
c_in = 0 (No CIVs incoming for trade, licenses, Puppets or occupation
c_out = 0 (No CIVs used for trade or buying licenses, or other constructions)
CPD = 0.0009 (Level 5 Infrastructure, 30% Construction Bonus [Export Focus, Construction1, Captain of Industry] )
Run it for 1000 days:
Ingame Testrun gives 79 owned CIVs, 57 CIVs available for construction and 2.09 incomplete CIVs in construction
Formula gives 80.36 owned CIVs and 57.89 available CIVs
The number of CIVs after 1000 days is 80. It takes over 3 years (1144 days) to double the number of CIVs.
Look at Graph:
(The dotted line "Linear (CIVs)" is a linear regression line from excel.)
(In a real game you would research more levels of construction, get new CIVs by focus, trade, conquer new CIVs and so on... This example is here to show only the exponential nature of building CIVs and that the effect is small.)
Implications and Conlusions
- When building CIVs the growth is exponential, but the exponential effect is low in typical time scales. If you looked at the function over 30 years, it looked like this:
There you see the impact of the exponential function. But you're not building CIVs that long.
- It's hard to calculate HOI4 economy in advance. There are so many things to consider and some of them have a random element like trade. It's not reasonable to find out every date when a law changes or when you hire an advisor to be able to calculate the economy. You can just do a testrun for that.
- What's the point of the thread then? It's to get a better understanding of the mechanics and to be able to answer specific questions. For example this one:
- In the example above you can decide between lowering consumer goods from 20% to 15% or raising construction bonus from 30% to 40%. Which is better for the construction of CIVs?
-> It's the -5% Consumer goods. (But it's only by 1 CIV in 2 years.)
- One idea behind making this a thread is to get questions from you. By trying to answer questions about the topic I hope to get an idea where I have to expand the formula.
Decisive factors for rapid CIV growth
Let's look at equation (3) again:
(3)
To have more CIVs available for construction you want to:
- Have a lot of owned CIVs, obvious. Thats why you build CIVs to have more available CIVs.
- You want to have more incoming trade and less outgoing trade. That's why you do tradebacks or even trade boosting in Multiplayer.
- You want to have the lowest Consumer Goods ratio possible. Lowering CG gives you more available CIVs IN THAT MOMENT.
- You want to have a low number of MILs. That's why converting MILs into CIVs at the very begining is a strategy. (I will address this in a future thread.)
(12)
In an exponential term of the form e^(k*t) the factor k determines the speed of the growth. We want a large k.
With the use of (1) we can write k as:
(15)
We can increase k and thus the construction speed of CIVs by:
- Building in high Infrastructure provinces. (We dont want to build Infrastruture first to construct CIVs faster, it's not worth it.)
- Getting construction Bonuses. Get a good trade law, get a good economy law, research Construction 1-5 and hire an "Captain of Industry"
- Lowering the Consumer Goods ratio. You can affect them with the economy laws, with the advisors "Financial Expert" you can do deals like giving Airplanes for lower consumer goods, there's the MEFO Bills for Germany, some decisions influence Consumer goods (e.g. Improved worker conditions) and so on...
- Concerning Infrastructure it's easy. You build in your high infrastructure provinces first.
- Next thing to consider is that lowering Consumer Goods is almost always better than the construction Bonuses. One thing is that going from 30% CG to 20% CG changes the (1-CG) term from 0.70 to 0.80 which is a increase by 14.28%. If you change the prodcution bonus from 30% to 40% by adding an advisor the term (1+Bonus) changes from 1.3 to 1.4 which is a increase by 7.69%. That is only a bit more of the half effect. Even going from 0 to 10% in construction Bonus is only +10.00%
- What's more if change Consumer Goods it also has the effect on equation (3) described above. It makes you CIVs available for construction JUMP UP.
- Example: 50 CIVs, 50 MILs, 30% CG. You have 20 available CIV. 30 used for CG. If you change CG to 20% you have suddenly 30 available CIVs. +10 CIVs with one change. By changing CG by x% you get x%of your (CIVs+MILs) as new available CIVs.
- That makes going from Civilian Economy to War economy a very powerful thing to do with only 150 political power. It makes basic CG go from 35% to 20%. And it adds 30% construction Bonus. (-30% before, 0% after) Thats going for example from (1-0.35)*(1-0.2)=0.52 to (1-0.2)*(1+0.1)=0,88 which is a increase of 69% !! +69% "construction speed" and +15%*(CIVs+MILs) more CIVs available for construction with 1 law change.
- See the graph in this posting: https://forum.paradoxplaza.com/foru...i4-1-civilian-factories.1448922/post-27181155
Edits:
Revision1: (21.12.2020)
- Correction factor 29/30 to take into account that CIVs that are constructed are not yet constructing anything. Thanks @ZebS98
- Introduced c_av(t) the number of CIVs available for construction to simplify the equations
- Introduced c_in and c_out instead of c_other because c_in is effected by consumer goods and c_out isn't. Thanks @el nora
- Redone all formulas and graphs
- Restructured Posting to reflect changes
- Added "Decisive factors for rapid CIV growth"
Last edited:
- 19
- 5
- 4