The Math of HOI4 - (1) Civilian Factories

  • We have updated our Community Code of Conduct. Please read through the new rules for the forum that are an integral part of Paradox Interactive’s User Agreement.

Simon_9732495

Lt. General
25 Badges
Feb 28, 2020
1.612
4.188
  • Crusader Kings II
  • Crusader Kings III
  • Europa Universalis IV
  • Europa Universalis IV: Rights of Man
  • Europa Universalis IV: Art of War
  • Europa Universalis IV: Common Sense
  • Victoria 2
  • Cities: Skylines
  • Cities: Skylines Industries
  • Cities: Skylines - Parklife
  • Cities: Skylines - Mass Transit
  • Cities: Skylines - Snowfall
  • Cities: Skylines - After Dark
  • Prison Architect
  • Stellaris
  • Hearts of Iron III
  • Hearts of Iron IV: Cadet
  • Hearts of Iron IV: Together for Victory
  • Hearts of Iron IV: Death or Dishonor
  • Hearts of Iron IV: Expansion Pass
  • Hearts of Iron IV: Expansion Pass
  • Hearts of Iron IV: La Resistance
  • Battle for Bosporus
  • Hearts of Iron IV: No Step Back
  • Hearts of Iron IV: By Blood Alone
Now that you have a formula and spreadsheet you are used to, would it be an easy thing to change some variables and run different graphs? Only if it is easy and you are willing, would you mind showing a graph for the same 44 civs and 32 mils, but with civilian economy and no research, no leader buffs, no trade? Basically a day one scenario, before any PP or research is used?

Green:
c_0 = 44 CIVs; m_0 = 32 MILs
c_in, c_out = 0
Infrastructure = 50%
Consumer Goods= 20% (War economy)
Construction Bonus = 30% (Export Focus, Construction1, Captain of Industry)

Orange:
c_0 = 44 CIVs; m_0 = 32 MILs
c_in, c_out = 0
Infrastructure = 50%
Consumer Goods = 35% (Civilian Economy)
Construction Bonus = -20% (Export Focus, Civilian Economy(-30%))

Simulation for 2000 days: (until 23.6.1941)
1608578930803.png


I also attached a copy of the Excel file I created the graph with.
 

Attachments

  • CIVs_copy.xlsx
    293,1 KB · Views: 0
  • 2
  • 1Love
Reactions:

Simon_9732495

Lt. General
25 Badges
Feb 28, 2020
1.612
4.188
  • Crusader Kings II
  • Crusader Kings III
  • Europa Universalis IV
  • Europa Universalis IV: Rights of Man
  • Europa Universalis IV: Art of War
  • Europa Universalis IV: Common Sense
  • Victoria 2
  • Cities: Skylines
  • Cities: Skylines Industries
  • Cities: Skylines - Parklife
  • Cities: Skylines - Mass Transit
  • Cities: Skylines - Snowfall
  • Cities: Skylines - After Dark
  • Prison Architect
  • Stellaris
  • Hearts of Iron III
  • Hearts of Iron IV: Cadet
  • Hearts of Iron IV: Together for Victory
  • Hearts of Iron IV: Death or Dishonor
  • Hearts of Iron IV: Expansion Pass
  • Hearts of Iron IV: Expansion Pass
  • Hearts of Iron IV: La Resistance
  • Battle for Bosporus
  • Hearts of Iron IV: No Step Back
  • Hearts of Iron IV: By Blood Alone
So what are now the decisive factors for rapid CIV growth?

Let's look at equation (3) again:

(3)
1608625480881.png
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 beginning is a strategy. (I will address this in a future thread.)
Now let's look at equation (12) that describes the growth of available CIVs:

(12)
1608626019415.png

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)
1608626384341.png

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...
But how to prioritize?
  • 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
 
Last edited:
  • 1
Reactions:

ZebS98

Private
Dec 20, 2020
11
15
Thank you for looking into it. Very helpful. I appreciate it!

I think you are correct.
I stated in the thread above that I might have to consider the effects that CIVs that are constructed don't construct anything in the future.
After I posted the thread I did some more testruns and noticed that the precision is not very good, if the amount of CIVs at the start is very high.
After your posting I decided, I should correct this immediately. The precision is ok, but better is better...

My idea to correct it is the following:
Say you use 60 available CIVs for 4 full construction lines to construct other CIVs.
(Available means the CIVs that are really consturcting after considering, trade, consumer goods and so on.)
That means in the best case all 4 lines are at 0% progress and all CIVs you have are actually constructing.
If all 4 Lines are on 50% that means you have 62 CIVs (4*0.5 = 2) but only 60 are constructing.
In the worst case all lines are almost finished, you have almost 64 CIVs and 4 CIVs that are not constructing.
Let's assume that the actual progress is normally distributed (like random, like white noise) which should be a solid representation. (As long as the player is not microing the construction.)
Then the average case is that: (Num CIVs / 15 ) / 2 are not constructing.

I'm going to correct the number of CIVs by that number.
But I think I'm going to start from scratch and make a formula for "CIVs available for construction" (The formula above is for "CIVs owned")
Wouldn't be the first time I start from scratch. :D

I attached some files that might help you.
 

Attachments

  • HOI4_CIVs.xlsx
    43,6 KB · Views: 0
  • CIVs.pdf
    141,4 KB · Views: 0

Simon_9732495

Lt. General
25 Badges
Feb 28, 2020
1.612
4.188
  • Crusader Kings II
  • Crusader Kings III
  • Europa Universalis IV
  • Europa Universalis IV: Rights of Man
  • Europa Universalis IV: Art of War
  • Europa Universalis IV: Common Sense
  • Victoria 2
  • Cities: Skylines
  • Cities: Skylines Industries
  • Cities: Skylines - Parklife
  • Cities: Skylines - Mass Transit
  • Cities: Skylines - Snowfall
  • Cities: Skylines - After Dark
  • Prison Architect
  • Stellaris
  • Hearts of Iron III
  • Hearts of Iron IV: Cadet
  • Hearts of Iron IV: Together for Victory
  • Hearts of Iron IV: Death or Dishonor
  • Hearts of Iron IV: Expansion Pass
  • Hearts of Iron IV: Expansion Pass
  • Hearts of Iron IV: La Resistance
  • Battle for Bosporus
  • Hearts of Iron IV: No Step Back
  • Hearts of Iron IV: By Blood Alone
I attached some files that might help you.

Please help me understand your point.
Is your point that the (continuous) exponential function shouldn't be used to describe the growth of CIVs? If that's your point, then why not?
In my opinion an exponential function with the correction I described above does it well enough.
Yes, it is possible to write some code that does exactly the same as the code of the game. But what would be the point?
As I stated in my conclusions, the main point of my analysis is to understand the mechanic better. That's why I try to formulate a simple function (here the exponential function) that describes game results well enough to understand it properly.
 

ZebS98

Private
Dec 20, 2020
11
15
Please help me understand your point.
Is your point that the (continuous) exponential function shouldn't be used to describe the growth of CIVs? If that's your point, then why not?
In my opinion an exponential function with the correction I described above does it well enough.
Yes, it is possible to write some code that does exactly the same as the code of the game. But what would be the point?
As I stated in my conclusions, the main point of my analysis is to understand the mechanic better. That's why I try to formulate a simple function (here the exponential function) that describes game results well enough to understand it properly.

You are right, I haven't been clear enough. The exponential model works fine. The thing I didn't think would work was your approach because, if you use the differential equation that gives you exponential growth, you are still implying that all output produces output. Of course you can correct the model in order to make it fit the actual number of CIVs and, as long as it works, I don't mind. It just feels a little bit like guessing. But hey, it's not easy and you are doing a great job. If you ever need an other approach, at least you have it!
 

Simon_9732495

Lt. General
25 Badges
Feb 28, 2020
1.612
4.188
  • Crusader Kings II
  • Crusader Kings III
  • Europa Universalis IV
  • Europa Universalis IV: Rights of Man
  • Europa Universalis IV: Art of War
  • Europa Universalis IV: Common Sense
  • Victoria 2
  • Cities: Skylines
  • Cities: Skylines Industries
  • Cities: Skylines - Parklife
  • Cities: Skylines - Mass Transit
  • Cities: Skylines - Snowfall
  • Cities: Skylines - After Dark
  • Prison Architect
  • Stellaris
  • Hearts of Iron III
  • Hearts of Iron IV: Cadet
  • Hearts of Iron IV: Together for Victory
  • Hearts of Iron IV: Death or Dishonor
  • Hearts of Iron IV: Expansion Pass
  • Hearts of Iron IV: Expansion Pass
  • Hearts of Iron IV: La Resistance
  • Battle for Bosporus
  • Hearts of Iron IV: No Step Back
  • Hearts of Iron IV: By Blood Alone
I'd like to compile a list of things to do, to influence CIV production speed. Maybe you can help me add the things I missed.

(And maybe some has an idea fo a better title of the list...)

List of decisions to influence CIV production speed
  • Infrastructure:
    • Build in provinces with high infrastructure
    • Build up infrastructure (Don't do it only for the purpose to construct buildings faster. It's not worth it only for that purpose.)
    • Infrastructure getting damaged
    • Reparing infrastructure
  • Economic Laws
    • Undisturbed Isolation | Consumer Goods 50% | CIV Construction Bonus -50%
    • Isolation | Consumer Goods 40% | CIV Construction Bonus -40%
    • Civilian Economy | Consumer Goods 35% | CIV Construction Bonus -30%
    • Early Mobilization | Consumer Goods 30% | CIV Construction Bonus -10%
    • Partial Mobilization | Consumer Goods 25% | CIV Construction Bonus 0
    • War Economy | Consumer Goods 20% | CIV Construction Bonus 0
    • Total Mobilization | Consumer Goods 10% | CIV Construction Bonus 0
    • Collectivized Society | Consumer Goods 15% | CIV Construction Bonus +15%
  • Trade Laws
    • Free Trade (Construction Bonus + 15%)
    • Export Focus (Construction Bonus + 10%)
    • Limited Exports (Construction Bonus + 5%)
    • Closed Economy (Construction Bonus 0)
  • Conscription Laws
    • Disarmed Nation, Volunteer Only, Limited Conscription, Extensive Conscription (Construction Bonus 0)
    • Service by Requirement (Construction Bonus -10%)
    • All Adults Serve (Construction Bonus -30%)
    • Scraping the Barrel (Construction Bonus -40%)
  • Construction Bonuses
    • Research Construction 1-5 (+10% each tier)
    • Advisor "Captain of Industry" (+10%)
    • Several country specific National Spirits, some gained by focuses (Is there a list of these?)
  • Consumer Goods
  • Number of CIVs available
    • CIVs from Export
    • CIVs used for Import
    • CIVs used to buy Licenses
    • CIVs from sold Licenses
    • CIVs from puppets
    • CIVs from occupations
    • CIVs to upgrade agency
    • CIVs for intelligence operations
    • CIVs for developing resources (not 100% sure)
    • CIVs for special projects, e.g. (repair the suez canal) (not 100% sure)


What's still missing?
 
  • 3Like
Reactions:

bitmode

1st Reverse Engineer Battalion
Nov 10, 2016
3.824
7.024
What's still missing?
The construction modifiers have state-specific equivalents prefixed with "state_", i.e. state_production_speed_buildings_factor as well as one for each building type, like state_production_speed_industrial_complex_factor. The former is used for LaR-Spain and several BftB-countries.
These modifiers stack additively with the country-wide ones.

The generic decisions Improved Worker Conditions and War Bonds affect CG.
 
  • 4
  • 1Like
Reactions:

desphorin

Captain
7 Badges
Nov 7, 2019
300
490
  • Hearts of Iron IV: Cadet
  • Hearts of Iron IV: Together for Victory
  • Hearts of Iron IV: Death or Dishonor
  • Hearts of Iron IV: Expansion Pass
  • Hearts of Iron IV: Expansion Pass
  • Hearts of Iron IV: La Resistance
  • Battle for Bosporus
I'd like to compile a list of things to do, to influence CIV production speed. Maybe you can help me add the things I missed.

(And maybe some has an idea fo a better title of the list...)

List of decisions to influence CIV production speed
  • Infrastructure:
    • Build in provinces with high infrastructure
    • Build up infrastructure (Don't do it only for the purpose to construct buildings faster. It's not worth it only for that purpose.)
    • Infrastructure getting damaged
    • Reparing infrastructure
  • Economic Laws
    • Undisturbed Isolation | Consumer Goods 50% | CIV Construction Bonus -50%
    • Isolation | Consumer Goods 40% | CIV Construction Bonus -40%
    • Civilian Economy | Consumer Goods 35% | CIV Construction Bonus -30%
    • Early Mobilization | Consumer Goods 30% | CIV Construction Bonus -10%
    • Partial Mobilization | Consumer Goods 25% | CIV Construction Bonus 0
    • War Economy | Consumer Goods 20% | CIV Construction Bonus 0
    • Total Mobilization | Consumer Goods 10% | CIV Construction Bonus 0
    • Collectivized Society | Consumer Goods 15% | CIV Construction Bonus +15%
  • Trade Laws
    • Free Trade (Construction Bonus + 15%)
    • Export Focus (Construction Bonus + 10%)
    • Limited Exports (Construction Bonus + 5%)
    • Closed Economy (Construction Bonus 0)
  • Conscription Laws
    • Disarmed Nation, Volunteer Only, Limited Conscription, Extensive Conscription (Construction Bonus 0)
    • Service by Requirement (Construction Bonus -10%)
    • All Adults Serve (Construction Bonus -30%)
    • Scraping the Barrel (Construction Bonus -40%)
  • Construction Bonuses
    • Research Construction 1-5 (+10% each tier)
    • Advisor "Captain of Industry" (+10%)
    • Several country specific National Spirits, some gained by focuses (Is there a list of these?)
  • Consumer Goods
  • Number of CIVs available
    • CIVs from Export
    • CIVs used for Import
    • CIVs used to buy Licenses
    • CIVs from sold Licenses
    • CIVs from puppets
    • CIVs from occupations
    • CIVs to upgrade agency
    • CIVs for intelligence operations
    • CIVs for developing resources (not 100% sure)
    • CIVs for special projects, e.g. (repair the suez canal) (not 100% sure)


What's still missing?

I think instead of saying build up infra is never worth it, perhaps find a formula to definitively say under what conditions it is not worth it?

For example IIRC Portugal's leader starts with a +20% bonus to building infra. I recall back then I did some calculations and figure that if you have a lot of build slots in low infra area (e.g. angola) you actually can earn back the initial investment of 1-2 infra within a year or two.

Maybe in the future if pdx overhauls infra then that formula can come in handy.

I will try to find if I have saved my calculations anywhere.

btw Merry Christmas to all you beautiful people!
 
  • 1Like
  • 1Love
Reactions:

bitmode

1st Reverse Engineer Battalion
Nov 10, 2016
3.824
7.024
Number of CIVs available
  • CIVs from Export
  • CIVs used for Import
  • CIVs used to buy Licenses
  • CIVs from sold Licenses
  • CIVs from puppets
  • CIVs from occupations
  • CIVs to upgrade agency
  • CIVs for intelligence operations
  • CIVs for developing resources (not 100% sure)
  • CIVs for special projects, e.g. (repair the suez canal) (not 100% sure)
I looked through the factory accounting a bit more rigorously. Some of it is very procedural and may be tricky to fit in a pure mathematical formula:

Pre-trade, a countries damaged and total controlled factories are collected from three sources with three decimal places of precision:
  • each controlled state's CIC/MIC/NIC and rocket sites, respectively scaled by 1 + local_factories (e.g. compliance, resistance, occupation law, Support Bulgarian Occupation decision)
  • the country's offsite buildings (e.g. Burma Road, various equipment purchase decisions etc.)
  • donated factories through the modifiers industrial_factory_donations, military_factory_donations, and dockyard_donations (i.e. for exiled governments)
These fractional numbers are then rounded towards zero as the countries controlled CIC, damaged CIC, controlled MIC, etc.

Next up is exchange of factories with other countries, which is counted in whole factories. "Export" in the furthest sense comes first, yielding "borrowed factories":
  • CIC from exported equipment licenses
  • CIC from exported resources
  • CIC and MIC from subjects. CIC_total * cic_to_overlord_factor and MIC_total * mic_to_overlord_factor (e.g. subject level and Ferdinand's Puppet national spirit), rounded to closest integer.
  • CIC and MIC from other countries. CIC_total * cic_to_target_factor and MIC_total * mic_to_target_factor (e.g. PRC Soviet tribute and... that's it), rounded to closest integer
  • You may note that CIC_total and MIC_total were not defined yet. Recursion (for subjects) and prayers (for other countries) cover those cases.
"Imports" are limited to the difference of total CIC and damaged CIC from the pre-trade phase and are accounted as "lended factories" (that's a word now, deal with it):
  • CIC for imported equipment licenses
  • CIC for imported resources
  • the limited CIC amount available for trade is used on a first-come-first-serve basis for above two points
  • CIC and MIC to overlord: CIC_total * cic_to_overlord_factor and MIC_total * mic_to_overlord_factor (same as above)
  • CIC and MIC to other countries. CIC_total * cic_to_target_factor and MIC_total * mic_to_target_factor (same as above)
CIC_total = controlled CIC + borrowed CIC

MIC_total = controlled MIC + borrowed MIC; (skipping over the further details for MIC)

Now consumer goods and special projects CIC gets calculated. The targeted amount for the former is CIC_total + MIC_total, scaled by consumer_goods_factor and rounded towards zero (economy law etc. as listed in the wiki). CIC_total - damaged CIC serves as an upper bound for CG

Special projects encompasses everything using the civilian_factory_use modifier (e.g. various construction decisions, resource prospecting, agent recruitment, agency upgrades etc.).

Regardless, if borrowed CIC is not enough, CG/projects are paid from controlled CIC - lended CIC. And finally if that's still not enough (leaving no CIC for construction), imports get reduced too. However many factories get allocated are counted as used.

There might be a bug here because CG and project CIC are accounted for independently. If CG and projects independently don't cut into imports, their sum potentially doesn't either even if it should. I don't have any of the prospecting or spy agency DLCs to test this but as an example, say a country has 20 CIC total and spends 5 on imports. If CG and projects are both 9 CIC, the country should be forced to reduce imports. But if my prediction is correct, trade will not be reduced because 9 < controlled CIC - lended CIC.

Now we're already assigning CIC to construction lines! Every line can use up to NDefines::NProduction::MAX_CIV_FACTORIES_PER_LINE (15) factories out of a remaining R = CIC_total - lended CIC - used CIC. If the overlord is already contributing to the construction line, the subject can only do what is left. No construction in provinces with land combat. Of the N factories being assigned, N - R + damaged CIC will be damaged, the others not.
 
  • 2
  • 1Like
  • 1Love
Reactions: