Hello! I’ve been drafted from EU4 to fight in the trenches together with the HOI4 team for a month and give some support on AI and performance. So I’m here to talk about those.
HoI4 Dev Diary - The Imperial Japanese Navy (AAR)
Archangel85, Vice Deputy Content Lead HoI 4
I’ve been mostly devoting my time into improving garrison orders to solve some really wonky cases that could happen. Like it placing two units on Magdeburg instead of Berlin letting the capital be completely exposed. But also focused on making the garrison work a lot better when you don’t have enough troops to cover every point in the order that needs it.
Hello, and welcome back to another Dev Diary from the frozen wasteland that is Sweden in January. Today, we will have another short AAR of a naval warfare scenario, similar to the one we did earlier about raiding and submarine warfare.
First I implemented a new tool for HOI4 to let us programmers visually inspect what the unit controller is up to.
This was played as an MP game between me and Niall (@Ceebie), with me defending the Empire of Japan’s honor against Niall’s filthy American imperialists.
Starting as Japan, I immediately face a number of issues that should sound very familiar: I have very limited resources, particularly in terms of oil. This is now a much bigger issue as I can still happily build ships and airplanes and tanks, but I won’t be able to run them for free. However, if I want to upgrade my ships (and knowing Niall, I absolutely do), I will need naval experience, and China is unlikely to provide me with a lot of it. So I need to run training missions for my fleet, which gobbles up fuel at a rapid pace (I could only take out my main fleet units for a few brief weeks before the fuel situation became critical).
After that came the big task, rewriting garrison order and how it assigns units. There’s been a lot of issues here and you’ve probably experienced them from time to time. Shuffling, units prioritizing the wrong states or provinces, the list goes on.
So what did I do that is new. Instead of having the old logic setting up rules for where units should go I went with a thing I hate. Mathematics. The main difference is that each state will sort of calculate how “painful” it is to remove a unit from it now. This means as each state goes through this, they will be trying to find the least painful way to perform the garrison order and will eventually settle on a sort of equilibrium.
It’s given us a lot easier way to control where units should go in a garrison and where they end up will match a lot more in style of the weights you can see on the pictures above.
A thing that we have been planning to do for a long time and finally got around to is to allow a more flexible way to control how the AI plays. We use a system we call “Ai Strategic Plans” for this. Its essentially telling Ai to act a certain way when it comes to national focuses and priorities based on scripted conditions. To put that in english I am going to hand over to @Bratyn for some examples:
At the same time, while I could trade for more oil, it will cost civilian factories which I desperately need to build up my own industry or to trade for steel to continue my military buildup. I decided to keep the trading for oil to a minimum in order to more quickly build up my industry and increase the size of my fleet.
另一个我们早就计划好而最近终于能开工的工作就是更灵活地控制AI行为。我们会用一个叫做“AI战略规划AI Strategic Plans”的系统来满足这个目标。该系统让AI在面对国策和预编好的脚本时能极其有效地以某种方式工作。让@Bratyn用人话来给大家举一些例子：
Some situations in which the new Strategy Plans have been useful is to ensure‘compatible’ AI behaviour in the case of an a historical Germany. A lot of the AI behaviours for the major European powers has been based on the assumption that Germany remains fascist and causes mayhem in Europe. This means that AI Italy would usually see Germany as an ally, and that AI France would eitheral ways go with the United Kingdom (if historic mode was turned on), or be so unpredictable that it was problematic for planning out and predicting alternate history scenarios.
Using strategy plans, we have made these AI nations partly behave more logical to the changing world scene, and partly ensure that the player will always havea challenging playthrough. Going democratic Germany, only to get your only enemy (Soviet Union) end up at war with both the Allies and yourself, is not avery fulfilling playthrough. Instead, a new strategy plan will now load for France upon German completion of the “Oppose Hitler” focus. This delays their pick of which political direction to head into until we have more information from the German player, essentially a ‘holding pattern’.
If Germany revives the Kaiserreich and chooses “Focus on the True Enemy”, France is released from the holding pattern and will go with Britain, forming a counter-reaction to rising German colonialism. Essentially, in this playthrough not much will change other than Germany being unaligned rather than fascist. The war will likely develop in a similar matter (though not on a similar timeline), with one war with the Allies, and one war with the Soviet Union.
My first target is, of course, China, and we start the war with them in the middle of 1937. It quickly becomes apparent that I underestimate the Chinese. Fighting rages hard along the border for several weeks, and a number of naval landings that attempt to force the AI to draw troops away from the main front are quickly contained by local garrisons, but at least not pushed back into the sea. Part of the problem is that the fleets tasked with invasion support contain some of my battleships, which eat up absurd amounts of fuel, and my attempts to turn the tide through prolific use of air support eat into my fuel supplies even more.
If Germany revives the Kaiserreich and chooses “Expatriate the Communists”, these communists will head to France and give them a communist drift national spirit. France is released from the holding pattern and will go communist, choosing to side closer with the USSR so that both powers can stand against the new Anglo-German alliance.
If Germany goes democratic, France is released from this holding pattern and will choose to Revise Versailles. Which direction they pick next is up to the AI, ensuring some unpredictability. France may go Communist and start their own faction, or join the Soviet Union, ensuring a two-front war if Germany goes to war with the USSR. Alternatively, the French may go fascist. They then will go for “Woo Italy”, creating a new semi-powerful Fascist faction in south-west Europe. Similar strategy plans for Italy (and liberal application of AI strategy values…) ensure this alliance is stable. A new focus for france “Dismantle the Democracies” becomes available if Germany is democratic, and the AI has a high likelihood of taking this when the Germans are already at war with the USSR. This makes gameplay more dynamic, and ensures Germany will have ample enemies to fight against even if they elected to go democratic.
By early 1938, we are slowly grinding forward and have managed to inflict serious casualties on the Chinese, but my fuel stockpile has shrunken to just 30 days of current use. I curtail air support to only support my main thrust and send the naval forces providing shore bombardment back to port. Progress slows, but eventually we link up with the landing forces, at least saving me from an embarrassing early defeat. The massive amounts of Land XP also allow me to run through the doctrine tree quite a bit faster than Niall could ever hope to. Sadly the war in the Pacific will not be fought on land.
如果德国选择民主路线，法国则会脱离观望模式的状态并选择修订凡尔赛条约。下一个方向朝向哪里则取决于AI，以确保一定的随机性。法国可能走向共产主义并建立其自己的阵营，或者与苏联结盟使德国在对苏战争时要面对两线的压力。另外，法国还可能成为法西斯国家。之后他们会选择“啊！意大利Woo Italy”并在欧洲西南建立一个近乎强权的法西斯阵营。意大利也有类似的战略计划（和其在AI战略参数上毫不受限的应用）以确保联盟的稳定。当德国选择了民主路线时，在法国的国策树中出现名为“驱除皿煮分子Dismantle the Democracies”的国策，而当德国与苏联正处于交战状态时，AI会有很高几率采取该国策。这会让游戏体验更刺激，并确保德国哪怕在民主路线下也有足够多的对手。
We also used AI strategy plans to teach the Chinese AI how to handle the Inflation mechanic and do things like making the PRC AI keep the peace in China when they are going for the peaceful takeover through the political struggle. All in all, to myself and @Archangel85, this has been (and will continue to be) an invaluable tool for ensuring believable and, most importantly, fun playthroughs for each a historical paththat one can take. We hope to continue building upon this basis and make nations ‘smarter’ in dealing with alternate history situations, or just general oddities that arise in the state of the world over the course of a playthrough.
Modders I am sure are going to like this a lot, so for you guys check out the example below for how it can be set up (regular humans without modding superpowers can safely ignore).
It would take until early 1941 for the Chinese to fall, even though the writing is on the wall by the middle of 1940. I blame the poor infrastructure and awful terrain in China - my leadership is, after all, beyond any reasonable doubt.
In the meantime, Niall has been quietly modernizing his fleet and has started his rearmament. While a good amount of his effort is spent on helping out the British in Europe, I have no doubt that he has something in store for me. While I was deeply engaged in managing the war in China, I received some out-of-game intelligence (Niall bragging in the kitchen that his destroyer swarms would annihilate me) that makes me realize that my fleet lacks some key capabilities. The starting Japanese light cruisers are fairly mediocre, most have been built during the 20ies and are not up to the task of winning a firefight against the likes of a Brooklyn Class cruiser with no less than 3 light cruiser battery modules. What I do have is a lot of torpedoes, and I invest a little into researching upgraded torpedoes and better launchers. The Japanese Long Lance national spirit gives me another perk, as it negates the enemy screening to an extend, which means that my torpedoes can hit his capitals even through 100% screening.
So while I was slowly grinding my way across China, I also decided on my buildup strategy:
No new battleships, since they eat up a lot of fuel and I have enough to cover my carriers. However, I did later decide to build at least one Yamato-class as an insurance against Niall developing modern battleships.
A force of 4 light carriers. Japan starts with two (Ryujo and returning fan favourite Hosho), with two Zuhio class building. While these only carry 40 planes each, they will be used to provide cover for operations in and around the Dutch East Indies.
A force of 4 fleet carriers, with another force of 4 joining later. Akagi and Kaga will be joined by 2 more Soryu class carriers and form the main strike force in the Central Pacific.
Late game performance have always been a tough nut to crack for us on our games. For Cornflakes we rolled up our sleeves and got elbow deep into the code to improveit the best we could.
A heavy emphasis on air defense and torpedoes. After researching dual purpose main armaments, I design a new destroyer class with improved AA and better torpedo armament. These are joined by a quartet of light torpedo cruisers from the Japanese focus.
In order to measure performance and see where it goes bad to better pinpoint what causes the slowdown I write a little script that generates this super sexy graph for us.
The fleet’s main objective, however, is to provide support for landings to seize resource rich a