• 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.

AndrisN

Private
1 Badges
Feb 16, 2010
23
26
  • March of the Eagles
Part 2. AI Naval composition and Fleet management
An often-repeated comment on the HOI forums is that AI fleet management and naval composition isn’t moddable (or at least very minimally), unless you have access to the hardcode. Some excellent modders over the years have mentioned this. I will go against this conventional wisdom, and put this out there:

There are some softcode workarounds available to modders, which can signficantly influence AI fleet composition, and thereby AI naval effectiveness. How?


Short answer:
By setting up a country’s naval OOB at the beginning of the scenario that follows and optimizes AI rules/priorities for naval composition. You optimize the AI’s naval groups in advance, and when the AI actually builds additional naval units during the game, they will put the correct unit in the correct task force, based on which task forces have “open unit slots” remaining.


Long answer:
A more detailed explanation is below. The naval OOB optimization process follows a number of the AI's rules, and requires some trial and error in HOI1. Once again, I will repeat the basic assumption of this series:

“To understand some of the AI and modding problems that HOI2 and sequels (DH, AOD, etc) face requires a look at the original game itself, HOI1 1.06c. Most of these so-called 'hard-coded' limitations were there, back then as well. If we can find a work-around in HOI1, we can most likely use that (or a similar) work-around in the later games. “


AI Naval Fleet Composition Rules

1. Rule of 5: AI likes 5-unit naval task forces, and will always reorganize its fleets to meet this optimal number. Naval task forces are defined as anything that does not contain a Transport unit. AI nations (re-)organize their task forces, so that none of the task forces have more than 5 units. This results in the next rule.

Edit: This golden rule holds for HOI1, and in many instances in the later versions for some of the lightly modded naval powers (such as France, Netherlands, even Japan etc). For the major naval powers, you will need to figure out what the number is: it might be 5, 7, 9, or even 12. This number will be the most frequently recurring naval task force size for a country, and should be easily identifiable with FoW off during the game.

Edit2: It is possible that the min_core_attack_fleets and num_attack_fleets commands in the AOD ai file (and similar in other sequels) triggers an in-game change in the optimal naval task force number for that particular country. Needs to be researched further

2. If at scenario start (say Jan. 1, 1936), there are task forces with 6 or more units (i.e. above optimal TF number), the AI will start moving ships from 1 task force to another, to get under the 5-unit limit for all TFs. This results in numerous 0 unit TF/ghost fleets that appear on the map for an AI country after scenario start. These were smaller (usually 1-3 unit) task forces consisting of escort ships, which were moved to a different TF, leaving 0 there.

3. AI will try to keep at least 1:1 ratio of capital ships to escorts in each task force. Capital ships include battleships/BC and all carriers, while escorts are DD. Cruisers are special in that they can go both ways, although typically CAs will be included as capital ships and CLs as escorts.

4. AI almost always keeps subs separate in HOI2 and sequels (this varies from HOI1, that could group subs with other capital ships or escorts)

5. Transports can have escort ships with them (also, heavy cruisers in HOI1, not sure if in sequels), typically up to 1:1 ratio, and transport fleets can total any number of units without the AI reorganizing.

6. Top-Down Rule: New naval units that are either produced by the AI or received through event by the AI during peace-time, are put in the 1st “available” task force (<5 units), as defined in the OOB from top-down for that country at scenario start, and based on the above rules 1-5.

Example: You have 4 task forces defined for Italy in the following order from top to bottom of .inc file: TF1 (2 units), TF2 (4 units), TF3 (5 units), TF4 (3 units) ->

1st 3 eligible naval units will go to TF1, 4th will go to TF 2, and 5th-6th will go to TF4. Think of it as sequentially adding units until each bucket is full (= 5 units).

What happens with the 7th and following units (i.e when all buckets full)? Typically, this is when the AI starts creating a large stack, since it has nowhere to put the additional units. In my experience, the large stack often ends up being TF1 (the 1st task force in the OOB, although its name likely has been renamed by the AI), but this may vary by HOI game.

Edit: I suspect that the single very large stack, like the Ghost Fleets, are opposite manifestations of a database issue with the Europa Engine. Namely, once the engine has set aside memory for a task force during scenario load, it can't delete and re-allocate that space, even if there are no units there. Similarly, the engine can't add memory to create a new task force, hence units start piling up in a stack, once all buckets are full.

7. CV/CVLs and BB/BCs cannot be kept on their own/without escorts by AI, and have priority taking escorts from other TF . AI will always add an escort (possibly even a CA) during peace-time.

8. CAs are usually the easiest to have a 1-unit TF for the AI. They are capital ships, but don’t have priority in getting an escort like battleships or carriers.

9. The above rules hold, when the country is at peace and the AI has most of its non-transport fleets anchored in home provinces.


Recommendations to Modders (this uses Optimal Naval TF number of 5, change as appropriate)


Following are some strategies to improve AI fleet composition through a country’s naval OOB in the .inc file at scenario start.

1. Understand that this requires a little trial and error. Some of the above may have changed for the different HOI2 sequels and based on patches. Play around with it (and see the below section on Measuring your Success)

2. In the OOB, the 1st naval task force should be a dummy task force (0 units), with an expendable leader that has no good traits/low skill.


Example:

navalunit = {

id = { type = 12153 id = 2 }
name = "Italian Navy Command Genoa "
location = 933 #Genoa
leader = 6147 #Ciano
}

Sometimes, the AI will always put an Admiral-level commander for the dummy task force. In that case, choose your worst Admiral and have him as the leader in the .inc file. Consider him lost/trapped as far as the AI is concerned.

Not sure why, but the dummy task force seems to make the AI redistribute better by redistributing less and keeping the original TFs in the .inc file. Maybe it doesn’t know how to handle a 0-unit TF, so it skips the whole process. You will be surprised how long the dummy sometimes stays around for the AI (it goes away on day 1 for HP).

3. AI country’s future, main transport fleet should be after the dummy. Any transports produced/received will go to this Transport fleet.


navalunit = {

id = { type = 12153 id = 21 }
name = "Naval Transport Fleet"
location = 897 #Messina
leader = 6163 #Paladini

division = {
id = { type = 12153 id = 211 }
name = "Quarto"
type = cruiser
model = 1
}
division = {
id = { type = 12153 id = 214 }
name = "Porto di Roma Squadroni"
type = transport
model = 5
}
division = {
id = { type = 12153 id = 215 }
name = "Giorgio Orsini Squadroni"
type = transport
model = 5
}
}

Try to have some CL and DD with them, but as long as the Transport/escort ratio is less than 1:1, any escorts produced will 1st go here. If ratio is >1:1, the extra escorts at scenario start will drop down to the next open “bucket”, and any newly produced escorts will skip this transport fleet until ratio is <1:1.

4. Break-up your historical main fleets, so that none have more than 7-8 units in the .inc file. If you don’t break them up, AI will and it will make relatively poor choices for redistributing the extra units. This is your chance to optimize the AI’s fleet

5. After the dummy task force and main transport fleet, you can start with your real task forces following the Top-Down rule. These should have 1 (or max 2 units) each. If 1 unit, then a CA; if 2 units, then a CA + DD or CA + CL. Example:


navalunit = {

id = { type = 12153 id = 23 }
name = "Regia Marina II"
location = 893
leader = 6149 #Denzi Amares

division = {
id = { type = 12153 id = 133 }
name = "Bartolomeo Colleoni"
type = cruiser
model = 6
}
division = {
id = { type = 12153 id = 125 }
name = "3a Divisione Torpediniere"
type = destroyer
model = 5
}
}

navalunit = {

id = { type = 12153 id = 27 }
name = "Regia Marina III"
location = 893
leader = 6161 #Mascherpa

division = {
id = { type = 12153 id = 142 }
name = "Duca D'Aosta"
type = cruiser
model = 7
}
}

navalunit = {

id = { type = 12153 id = 28 }
name = "Regia Marina IV"
location = 893
leader = 6158 #Iachino

division = {
id = { type = 12153 id = 181 }
name = "Armando Diaz"
type = cruiser
model = 6
}
}.


If you expect AI country to build/get 30-40 additional ships prior to going to war, expect to have 7-10 of these 1-2 unit task forces near the top of the OOB.

6. Ironically, your historical main fleets should be towards the bottom of the OOB, instead of the top, where they have typically been. These will usually LOSE units to other task forces to get under the 5-unit cap.

7. Other transport fleets and any additional 1-3 unit task forces should be at the bottom of the OOB. Likely, these won’t be touched by the AI, provided you followed AI Naval Fleet Composition Rules for the preceding task forces. These task forces will usually have the same number of units for as long as country is at peace.

8. I recommend having a 1-unit, 2-unit, and 3 or 4-unit transport fleet, plus the main transport fleet. Having multiple same-sized transport fleets doesn’t help the AI, as it usually has a hard time breaking down land units to fit onto the transports.

9. If you make the AI country build so many ships that all its buckets are filled, there will be one big stack that gets all the overflow units. Try to plan ahead to avoid this, as some games give severe penalties for stacking.

10. On the other hand, the AI should start to create some large transport fleets, comprised of 5-10 escorts and 10-20 transports. This will allow for some large-scale AI amphibious invasions (see Part 3), which is very good and much needed.


Measuring your Success

1. I’ve found that the best way to measure how well you follow the AI’s hardcoded fleet composition rules, is to see the number of “generic fleets” it created after AI fleet distribution is complete (typically couple months after scenario start). A “generic fleet” is one that has been renamed from its initial name in the .inc file

The less renaming going on, the less redistribution by the AI -> the better you are doing. In some cases, I have managed to have all but 1 fleet, keep its original name.

And then, you will start to see the new naval units drop into the 1 or 2 unit task forces to fill those buckets. Based on the order these are produced, you can effect which task forces these units end up in.

2. AI fleet management is different during war-time in HOi1 (may vary in sequels). It will start attacking with full TFs (sometimes 9-12 units or even bigger), but will send out 1-2 unit TFs (including unescorted BBs and CVs), if these are the only non-transport groups left.

The primary goal in war-time is to try to keep the AI in port for a while to “rebuild” its TFs, so that they aren’t destroyed in detail. When this is done (for example, during Fall Gelb when Kriegsmarine is usually in port), new units will be added in the manner above. As a result, the AI can rebuild pretty quickly and pose a renewed threat to HP.


Conclusions
In general, the AI fleet won’t be as efficient as a HP fleet. That said, in my experience following the above creates better AI fleets than currently in many mods. The AI fleets are more diverse, have better overall attack/defense, create larger transport/escort fleets, and possibly create a greater challenge for HP.
 
  • 2Like
Reactions: