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.
Showing developer posts only. Show all posts in this thread.
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.

Currently handled dynamically. So such specifics are not very modable atm.
 
  • 3
  • 1
Reactions:
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 ...}

As I am currently working with the system I cannot commit to an answer to this at this time.
 
  • 4
  • 3
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?

By and large; yes, they will.
 
  • 6
Reactions:
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!

Thank you. I am most of all happy that I do not carry this burden alone. QA, Wiz, Groogy and betas are all pitching in with important work.
 
  • 8
  • 1
Reactions:
Sorry just seeking clarification. Yes they will focuses on Russia? Or yes they will make life hard for Germany anyway?

Sorry for being to brief; the democracies will pick up on who generates threat and will generally work towards containing that threat and protecting smaller countries (primarily democracies.)
 
  • 8
  • 3
Reactions:
No, I mean like how in Europa 4 a human player's country can never be inherited by an AI, but the AI suffers no naval attrition, and the AI gets an extra diplomatic relation it reserves for the use of the player.

One thing I saw in HoI4 was that there are some diplomatic options where you get a big bonus to the AI's chance to accept the deal because you're a human player.

Ah. That bonus is for desire to join/create factions only, and is meant to aid in more sandbox style play. On higher difficulties the AI may be given some boosts to things like research times and production efficiency, but at base line all countries are equal in terms of game rules.
 
  • 5
  • 1
Reactions:
Thank you for the answer.

A last question, in HOI3, the AI often do strange actions, as Germany sending all the troops build for barbarossa in Norway in case of stalemate. Or sending 40 divisions to hunt a single division behind the front-line. Does the new AI will be able to respond proportionately to the threats?

X.

Determining what is proportional can be very difficult, and balancing stuff like this has been one of the greater challenges. I am not saying it is water tight, and some mistakes are sure to occur, but largely it does seem to be fairly good now.
 
  • 4
  • 1
Reactions:
First, Thanks for your hard work on the AI.

You did not mention, for most guys, the most important feature of the AI for a player?
When the AI is attacking, will it surround enemy units and kill them. Guys really like to see this in Darkest Hour for instance.

Guys don't want a broad front of units all attacking at the same time. They want to see some units charging ahead, surrounding the enemy where possible, and then annihilating those units trapped in the "kessel".

Can your AI do this?
If not, do you think with some work (by modders maybe?) it could do this?

Thanks Again.

It has been known to happen, but typically it is due to the AI taking advantage of situations that happen to occur. Give it an opening and the AI will use it.
Specific unit movements will unfortunately not be moddable, but I am continuously thinking about how I can improve on things like this to make the AI more effecient.
 
  • 4
Reactions:
@SteelVolt I would like to inquire again which aspects of the AI are open to (heavy) modding. I understand the dynamic AI underpinning the game can be tweaked via changing the factors. What else is possible? The game can be divided up into several areas very important to the AI.

Production - Can we script build orders to trigger dynamically (usually in response to certain dates date/war/victory conditions), especially implementing new units and triggers? This is different from changing the weights of equipment.
Research - Dynamic triggers to rush ahead of time tech in response to battlefield conditions or national foci would be great here
Land Combat - I'm not hopeful for this since I understand this is much valuable in terms of IP, but anyway to tweak the combat AI especially with regards to stance (seems to be gone now), and deployment orders?
Naval Combat - Are we free to define fleets types, patrol areas and/or missions for the AI to follow?
Air combat - Similar to naval combat, what's the potential for modding

Lastly since no one has asked yet, what language are we looking at when coding scripts for the AI to follow?

Generally speaking, I think the more exposed the AI logic is to tweaking especially the subroutines, the better the game will age with mods. If possible try to let us have access to the underlying logic rather than just the 200+ triggers/modifiers/factors involved!

1: No.
2: You can tweak weight for individual techs and foci, giving this effect.
3: No.
4: Not at the moment, no.

The language is our internal scripting language. As was stated in the mod DD and one of my replies here, we are no longer using LUA for scripting.

Still, while I want to make as much as possible available through script, I need to take into account the time it takes to do that compared to making a dynamic solution, as well as which approach gives the best results, primarily for release.

I too am looking forward to see what the modding community does with HoI4 :)
 
  • 3
  • 1
Reactions:
Of course, I can`t tell AI to do naval invasion, but unless I tell AI to build a navy, marines and such, AI will never invade anywhere ;)

It was possible to make German AI to make sealion, I needed to give it all the resources (navy, naval bombers, marines) and then, it typically would do just that, even air battle for Britain was possible with enough German planes. Obviously, no guarantees, but it was pretty stable and reliable ;)

I`m interested if such functions are possible to implement in HOI4 in principle, LUA or not, i don`t particularly care, if anything, C++ is my working programming language ;)

Is there some sort of country-specific set of "pointers" that a modder can use to dynamically alter what AI strategy is? It would be great if we could at least have dynamic allocation of weights, based on conditions ;)

If you give it the resources and set up a war it is likely to happen, sure. What you cannot do is define the specific behavior, just nudge it (for some things pretty hard) in certain directions.

Since the scripting language is our own internal one, you cannot script algorithms, as such. Please read the modding DD for more info, as the system is the same as for the AI :)
 
  • 2
Reactions:
So if I understand you correctly, there's no possibility of any mod with dynamic solutions if all the dynamic solutions are internal and baked into the exe?

I foresee a lot of scripting "abuse" coming in the mods if this is the case, to push the AI past what you guys ever intended :p.

Yup, pretty much.
 
  • 2
  • 1
Reactions:
So how will ai naval invasions be handled in general? Also all nations will in some degree do them looking for weak spots like innl your example or just specified ones like usa or gb?

The AI tries to draw naval invasion plans the same way a player would. No country is blocked from it, but you do need naval supremacy to carry them out, giving England, USA and Japan an edge from the start with their big navies.
 
  • 2
Reactions:
@SteelVolt On a separate note, if you could help comment (document) on what the 200+ modifiers (and indeed for all the other defines) are actually used for, in which specific algorithm and the underlying logic, that would save us years of experimenting. It took the HOI3 community ages to even figure out how combat resolved, and without access to the underlying code having so many modifiers to tweak feels like firing shots in the dark for such a new AI system.

All of the defines have descriptions to aid with this.
 
  • 5
  • 3
Reactions:
But what can I script is the question!
What is even an option, aside from NFs and events?
Production "weights"?
Army composition "weights"?
Any option to tell AI where to invest it`s civilian factories? (more military factories/naval yards/civilian industry, ex)
Any options to tell AI what it needs to prioritise during expansion?

A complete list would take too much time and effort right now, and is subject to change (mostly additions), but very few parts are completely walled off. Where values are used to determine things, they are usually available for tweaking.
 
  • 5
Reactions:
I appreciate those, but having some elaboration on the logic behind it help us understand the range of values and effect each modifier has. For example, toughness/defensiveness were factored into combat in HOI3, but was not fixed for the longest time since the 0.8 chance to miss should have been 80. Putting it down might help spot errors like that when you say

-- rand(chance to miss/100, toughness) * soft attack = shots hit
or another example
-- AI multiplies WT * factor_1 * factor_2 and if this is less than factor_3 they DOW.

It's much clearer how we should use the modifiers, and what range won't break the code. Any notes will be much appreciated, and thanks for your hard work making HOI4 great!

I understand the frustration. Often the thing a factor is multiplied by is not so basic as "WT", but may be something like "WT change over the last month divided by country size if minor and army size if major". I try to be as clear as I can in my descriptions, but we do have staff who actively works with supporting modders, and they should be able to answer questions if something is really unclear when you try to use it.
 
  • 3
Reactions:
First off let me say that HOI4 fixes everything I didn't like about HOI3. Id play HOI3 over and over and when I got to the invasion of Germany or Russia depending on what nation I played my head exploded...

Maybe that's partly because in the WWWs naval action has been largely ignored.

In another thread there is some talks going on about how the AI moves troops into another country and nobody replied to this aspect of it.
The 2 examples that showed up in the last WWW was:

1 - Germany moved dozens of troops into neutral hungry to attack Poland. My question is why and how?
2 - Daniel was able to move troops thru Russian controlled Poland to attack Germany... Same questions.

They weren't allied or at war IMHO Nations shouldn't be able to move into other nations without permission or a DOW


Anyway that's for your time and every ones hard work. Cannot wait til the game comes out.

The WWW have primarily been about what people have asked to see.

1 - Yeah, there is a known issue with AI drawing front lines along fronts it cannot attack over. I have an issue on it, and it should be a fairly easy fix :)
2 - If two countries are at war with a common enemy they can move through each others territory. This rule is a design choice completely unrelated to the AI.
 
  • 6
  • 2
Reactions:
Sorry one more question about the AI.

If I played the USA and I invaded Germany occupied lands would the AI England follow up my invasion with troops and help after they did their plans ect...

They _can_, but it is a balancing question if they would or not. Nothing is really stopping them from helping out, though.
 
  • 3
Reactions: