Hearts of Iron IV - Development Diary 54 - AI

  • 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.
Awesome work! I hope I'll have time to play this on release with Stellaris on the horizon and my workload at work which will be increasing from middle of the year!
 
Another example:

I implement "Nightfighters" as a subclass of heavy fighters with much higher night fighting capability.
-Is the AI aware of it and uses them mostly on night defense?
- Can the AI decide "oh, I need only 25% nightfighters and 75% heavy fighters, because nightfighters are more expensive?

Similar example:

I have "big "fleet submarines" with long range and "medium submarines" with lower range.
- Can the AI see that I need as Japan way more long range fleet submarines because of the longer distances to enemy convoys?
- Can the AI see that I need as Italy way more medium range submarines because of smaller distances to enemy convoys in mediterranian sea?


Or at least:
-How can we mod this in?
-What can be done to get good results?
 
  • 1
Reactions:
Not sure what you mean by this. By tweaking various values you can significantly alter the behavior of countries, but the underlying algorithms are C++, and as such not changeable through scripts.
Let`s say I want AI to launch invasion of Romania if AI can`t purchase Romanian oil for some reason, being either their law, prohibiting them from trading, or them being of wrong ideology.

I would need to determine IF Germany has troops to spare, are those troops strong/weak/mediocre compared to Germany, what kind of countries can jump to Romanian defence. Let`s say it is a national focus, so if conditions are fine, Germany declares war. That is what I mean. How complicated of a logic can we put into this scripts?

Or, let`s say I want AI to occasionally try different troops composition. So, let`s say I want Germany to have 3 broad strategies:
-historical
-focus on cheaper troops and faster wars, motorised instead of tanks, ex.
-go for navy.

I want the plan being set somehow, and then AI knowing it, would work towards it, let`s say a hiden event, depending on who player is, picks an AI strategy, depending on some weights.

Can I make all areas of strategic AI to work with the plan?

In HOI3, I would just set a country flag, and then would check the flag in country - specific LUA script.

Can something like this be done for HOI4?
I cannot say either yes or no with any conviction here. The AI does know things like taking advantaage of weak spots etc, and the multiple systems that touch movements and priority can certainly give rise to such behaviour. But planning large complicated operations in advance is tricky. Something I want to look more at in the future.

Also keep in mind that the AI is still in deveoplment, and will continue to be improved even beyond release :)
It doesn`t have to be huge, even if AI would be able to consistently recognise and exploit small 1-5 divisions 1-3 province pockets, it would be huge improvement ;)
 
Some question about AI that come to my mind :

- Did it uses xp to make variants ?
- How it handles research to make new division template ? Is there any "pre-made" template with latest tank/infantry equipment researched, or did the AI make his own according to some algorithm ?
- Last but most important : are the naval invasion by AI in HoI 3 corrected ? I saw Australia launch an invasion of Yugoslavia with one division like a suicide in the last WWW, it remember me the AI of HoI3 when USA send 2 infantry division in Murmansk or 6 armored division in Holland without support... It's my greatest fear, as without a proper uses of naval invasion by the AI, USA and Japan are doomed to make nothing...

- Yes, same rules apply as for human players.
- While "target templates" are scriptable, the AI creates them using the same functionality as the player. The research it picks depends on many things.
- While I never worked on HoI3, the naval invasions in HoI4 are shaping up fairly well. Still some minor hickups to take care of, but it is looking promising.
 
  • 17
Reactions:
Good Read. Intresting stuff. Most of the time AI countries getting cought unprepared is there are going to be "helping" feature to make sure they are ready for war?
Also Is there going to be second AI diary for Battle AI? Thats the other half of the gameplay.

AI countries are actually reluctant to enter wars before they are ready, and try to prepare as soon as they pick up on anyone generating a wargoal against them or taking a national focus that will likely lead to war. If you want to help your allies out, you have some options: leandleasing equipment, stationing your own troops on the relevant borders in their territory (which you can give them as expeditionary forces if you want to).

The DD schedule is unfortunately filled. As for the battle AI, I assume you mean how the AI carries out drawn plans. The short answer is: as straitforward as possible without making obvious mistakes. The long answer is that it is probably best to read the battle plan AI and then watch the WWW streams.
 
  • 12
  • 2
Reactions:
@SteelVolt
Important things for modders:

1) How hard/easy is it to implement new unit types and tell the AI how to use it and how much to produce (balancing production numbers)?
1a) F.e example I want to add escort ships. So they have Special Tasks:
- Do not mix with fleets
- Just go for submarine hunting
- go mostly on convoy escort duty

2) Can we tell the AI some Kind of production Ratio, or at least how does AI handle and itself produce and develop the techs of them?
- So AI sees the use of it
- AI decides how much are usefull of them (because of the missiontypes it has)

In Hoi3 I find it very complicated because of lacking programming/Scripting skills

The production part is highly scriptable, but roles are less so, at least for now. Hope that answers it.
 
  • 13
Reactions:
Awesome DD, and one I have been waiting for for a long time!

Really interesting to see how everything is working behind the scene One question though, purely out of interest:

How did you start building up the AI? I mean, what part did you start with? Is there some base in the Clausewitz engine or did you have to start from scratch? If so, what part did you start with?
 
Hi @SteelVolt and thank you for this good DD.

Can you tell us how the AI will set her priority and if those priority will be modable?
Exemple :
- the AI need tungsten, one of her neigbours had some, so she launch an invasion
- the AI can bomb two regions, but only one efficiently, one is full of factories, the other not, so she decide to bomb the factories ....

X.
 
Cheers for the DD Steelvolt , and to you, Wiz and Groogy for all your work :D. Really looking forward to HoI4, and for me the AI is the most important part, and it looks like it's in a good pair of hands :). So much coolness in the various scriptable features - specific behaviours for different leaders is brilliant (and will be a boon to modders), as is the peace deal side of things and being able to push the AI towards specific templates (presumably altering this based on whatever triggers we roll with?) Debug view also all kinds of awesome :).



Does this mean the AI has both the Battleplan AI (shared with player) and it's own "tweak things to deal with situations as they arise" AI? Very cool if so :).



On the first - big props, non-cheating AI is always my preference :). On the second, will it still be possible to mod in a bit more coup and influence party popularity-friendliness for crazy sandbox games?



Only answer if easy, but are there triggers for intelligence (ie, is it possible for an AI UK to focus production more on battleships if its intelligence sees nations its threatened by (or GER/JAP specifically, however it's best to set it up) building BBs, and similarly if instead it sees Germany building a stack of u-boats, to focus on destroyers instead?


Thank you :)

1: The AI is capable of micromanaging units beyond what the battle plan system does to take care of certain types of situations. Just as the player is expected to.

2: I will try to take the time to have a look at this!

3: Short answer: no. What makes it hard is that neither the player or the AI has access to info about what other countries are producing. Naval production also tends to be largely long term. But the balances are scriptable.
 
  • 12
  • 1
Reactions:
Does this mean there will be leaders like Patton who are much more aggressive (risking losing more troops for a faster land win) and more careful (risking less troops but advancing not so fast) leaders like Montgomery?

Currently these traits are primarily for country leaders, but I hope to expand on it and it would be cool to do something like that.
 
  • 9
  • 5
Reactions:
The production part is highly scriptable, but roles are less so, at least for now. Hope that answers it.

Thanx,
hopefully AI at least checks units and decide which is better used for certain tasks.
Some routines for telling the AI which tasks they should prefer would be good.

Can we define generally which tasks a ship can use like for planes and tell the AI? I'm not sure

F.e.
Destroyer ={ patrol=yes; search&destroy=yes; convoy_Support=yes ...}
Escort ={ patrol=no; search&destroy=no; convoy_Support=yes ...}
 
Battleships are weaker to airplanes(Relies more on heavier guns rather than AA), so in this case it would better to invest in Naval bombers and carriers. If you invested in Cruisers or Destroyers, then it would be easier to invest in Battleships. Naval battle is more of "what counters what".
It doesn't make much sense. Nation without any good AA did not, in fact, rely on AA, but ones with good AA (like the late-war USA) made their battleships into AA platforms that minced plane wings. One should look at American battleships to see the full possible effectiveness of the category; Japanese or Italian ships ignored the issue so completely it gimped them (even though the Vittorio Veneto battleships mounted some great AAA - just not enough in number).
 
  • 1
Reactions:
Let`s say I want AI to launch invasion of Romania if AI can`t purchase Romanian oil for some reason, being either their law, prohibiting them from trading, or them being of wrong ideology.

I would need to determine IF Germany has troops to spare, are those troops strong/weak/mediocre compared to Germany, what kind of countries can jump to Romanian defence. Let`s say it is a national focus, so if conditions are fine, Germany declares war. That is what I mean. How complicated of a logic can we put into this scripts?

Or, let`s say I want AI to occasionally try different troops composition. So, let`s say I want Germany to have 3 broad strategies:
-historical
-focus on cheaper troops and faster wars, motorised instead of tanks, ex.
-go for navy.

I want the plan being set somehow, and then AI knowing it, would work towards it, let`s say a hiden event, depending on who player is, picks an AI strategy, depending on some weights.

Can I make all areas of strategic AI to work with the plan?

In HOI3, I would just set a country flag, and then would check the flag in country - specific LUA script.

Can something like this be done for HOI4?

It doesn`t have to be huge, even if AI would be able to consistently recognise and exploit small 1-5 divisions 1-3 province pockets, it would be huge improvement ;)

You cannot set the AI to "make a naval invasion plan against country X", that is handled dynamically. What you can do is push the country in the direction of war, but how exactly the war is fought is determined dynamically.

We are not using LUA for HoI4. This was a decision made before I started working at PDS, and was based primarily on lack of in house LUA skills and performance cost.
 
  • 13
Reactions:
I am sorry if this has been asked and answered and if so if someone could be so kind as too show me the answer please do

Will the AI democracies focuses their ire on those countries doing the tension raising? Like if I play as Germany and Russia raises WT to a great degree will the AI focus on them or go about and make my life harder anyway?
 
You have the hardest & I think the most important job in the Development of HOI IV! I know you didn't work on HoI 3 and that is the most broken thing with that game. If the AI of HOI IV is bad no matter how good the rest of the game is it will be a bad game. So on your shoulders rest the fate of HOI IV!

The very best of wishes!
 
  • 5
Reactions: