HOI4 - Together For Victory AI Update #3

Showing developer posts only. Show all posts in this thread.

SteelVolt

Technomancer
2 Badges
Aug 4, 2014
735
4.200
  • Paradox Order
  • Hearts of Iron IV Sign-up
Hi everyone!
It is me again; your friendly neighbourhood AI developer. Today I will move on from focusing on bugs to looking at what we consider improvements, though as I stated at the end of the last diary the line between the two is very blurry when it comes to the AI.

This is the third installment of these mini diaries, and if you missed the other you can check out #1 (scroll to the bottom of that diary) and #2 respectively.

But to kick it off I thought I would tell you yet another story from the trenches.
We often run the game hands off over nights to see how it progresses for various countries, such as how the Japan vs China conflict works out. Some months before release I found an overnight had gotten a very surprising result: Italy had annexed almost the entire Soviet Union, while Germany had completely opted out of any Soviet territories. If any country beats Soviet Union, it does certainly NOT tend to be AI Italy, so something was clearly up. Going back in the autosaves we could see that it was indeed Germany pulling the most weight in the war, so the conclusion was that something unintended was going on in the peace conference. Letting the game run through the peace conference the crazy result was easily reproduced; Italy would consistently take Soviet territory, while Germany opts out and thus pass on their war score to Italy. So the question remained: why?
After a little digging I found that the fascist peace conference AI was set up to want to take neighboring territory, but be very reluctant with non-neighboring areas. But clearly Germany must have been neighboring Soviet? Well...in a sense. They had indeed defeated Poland before taking on the Soviet Union, but they were only occupying Polands states, since Poland had joined the Allies, which had of course not yet capitulated. Since we separate ownership and control of areas, and the neighboring check looked specifically at ownership (after all, Germany was not guaranteed to get to KEEP Poland), they ended up ignoring Soviet areas as NOT connected to their own areas, while Italy had annexed Romania in an earlier war and considered their areas as connected by land to Soviets.

The peace conference AI has since been refined to avoid silliness like this, but it does serve to illustrate how you need to keep a lot of different potential situations in mind when designing and programming AI. And this is far from the most complicated systems.

Today I will introduce something brand new; my work on encriclement AI!

- AI now attempts to detect and react to many encirclement opportunities, both against itself and against enemies. Includes evacuating dangerous areas and cutting off bottlenecks.
  • Detecting potential encirclement situations is a really hard problem. A human, with her superior pattern recognition abilities, can take a glance at a map and point out such situations in practically no time at all. A computer, not so much. The thing is that you need to consider the relation between at least five or so provinces to detect the smallest encirclements, and for large ones the number gets really big. Computers are inherently bad at considering more than one relation at a time. While the approach for narrower bottlenecks and larger encirclement patterns is somewhat different, and particularly the latter is not 100% accurate, but where to draw the line between potential encirclement is not always clear anyway. The type of reaction varies a bit depending on the situation detected, but all in all the AI is better at countering attempts at encirclement and to try to act on opportunities they get. Though there is of course room for some improvement I must say I am quite happy with the number of situations the AI is actually able to detect with relatively few false positives. I hope this makes the game both more challenging and engaging for you!


Of course, I cannot only leave you with only one point, even if it is a big one, so I will also use this diary to talk a bit about defensive AI.

- Split up AI garrison order in two: home area and other areas.
  • For a country like Germany, using a single garrison order is fine. For a country like the Soviet Union or even France, they risk having units sent around the world, not doing much to help at all, just because the order mechanic is attempting to balance the units inside the order. Not to mention how strangely balanced the spread becomes due to area around the capital typically gets too few units while far away areas ends up with too many. Splitting up the order greatly improves the AIs ability to defend. The units move around less withing each order, and the AI can balance between oversea areas (or...you know...Siberia) and the area around its capital.

- AI is no longer using all types of garrison locations.
  • The AI can and does indeed make use of this new feature. In many situations it is a waste of units to garrison everything you possibly can. While being on the offensive, garrisoning your forts can typically be wasteful if not all ports are covered to defend against potential invasions.

And that is all for today. Next time (which is probably going to be wednesday) I intend to be talking about boats and boaty related stuff. Until then, I am getting back to work on more improvements for future updates.
 
  • 65
  • 36
Reactions:

SteelVolt

Technomancer
2 Badges
Aug 4, 2014
735
4.200
  • Paradox Order
  • Hearts of Iron IV Sign-up
- do we get any new defines/scripting options/ai strategies for encirclements/garrison orders?
There are a few new defines to play around with, but that is all. But please post requests for mod features in the mod forum or suggestions forum :)

- does the AI's interest in offensive encirclements have any relation to the availability of mobile units (arm, mot, mec) that might make such operations easier to pull off?
Not at the moment, but there are plans for future improvement.

- we haven't heard much about air unit allocation. The last vanilla games I've played, the AI has liked sending its aircraft all over the place (most of the Luftwaffe in China, SEA and Japan and things like that)?
Just a bug fix or two, but some more proper stuff is in the pipeline.
 
  • 5
  • 1
Reactions:

SteelVolt

Technomancer
2 Badges
Aug 4, 2014
735
4.200
  • Paradox Order
  • Hearts of Iron IV Sign-up
@SteelVolt

Thanks for the update.

Though its not to do with this DD or you might mention it later I'd like to ask a question.

Leaving aside the controversy of the Spearhead command, I'd like to know will the AI use it regardless of whether you own the DLC or not? I would strongly argue that it should get to use it even if you don't have the DLC, because any help the AI can get is good IMO.

Unfortunately the AI does not use it in the current build. The reason behind this being that it would be tricky to get good, and in stead of adding a thing that the AI did half right we focused on improving the existing areas where it has not been performing as well as desired. But I certainly see your point, and it has been discussed internally as well.
 
  • 7
  • 1
Reactions:

SteelVolt

Technomancer
2 Badges
Aug 4, 2014
735
4.200
  • Paradox Order
  • Hearts of Iron IV Sign-up
Glad to hear it, thank you. :)

By any chance, do these improvements also apply to the troops on a front? The battle planner seems to enjoy shuffling troops around longer fronts, keeping them from getting planning bonuses or thinking all the units are in position in order to attack.

There is a partial overlap yes, and there has been some tweaks done to the front handling as well, but not as a main focus.
 
  • 4
  • 1
Reactions:

SteelVolt

Technomancer
2 Badges
Aug 4, 2014
735
4.200
  • Paradox Order
  • Hearts of Iron IV Sign-up
Thanks for the info @SteelVolt

I have a question partly base on what you bring up here & defensive garrisons. If I were going to give an AI controled country a bunch of weak forces (maybe to defend low priority borders of Czechoslovakia or Poland or to defend the long coastline once Germany controls most of Europe or just to sit on VP provinces) through an event would the AI use them for lower priority duties and use the better forces for the major offensives/fromts?

The garrison order would grab the shittiest unit first, and then fill out with less shitty if it determined to need more divisions to cover the order, while the oposite is true for other order types. This is something I would like to spend more time on improving, but the intention is to concentrate weak forces in garrison orders and let the other orders grab the good ones first.
 
  • 6
Reactions:

SteelVolt

Technomancer
2 Badges
Aug 4, 2014
735
4.200
  • Paradox Order
  • Hearts of Iron IV Sign-up
Hi SteelVolt, what I would really like to see is an AI that is capable of using terrain specific units. Currently the terrain modifiers are much too low IMO, but you can't increase them because the AI doesn't know how to use them. Would it be so hard to have the AI assign mountain units to a theater with lots of mountains for instance or cavalry to deserts and tanks to plains? Not necessarily have them fight only in those tiles but at least assign the right units to the right frontline.

Even worse, the AI seems to be incapable of distinguishing between frontline units and suppression/garrison units.
Fixing this problem would go a very very long way towards improving the AI.

For the first point, the AI does try to determine the important terrain types when assigning units to orders. The theatres are not really a map concept in the background in HoI4, but rather a tool for players to organize their groups. At any rate, I agree that there is a lot of room for improvement, but not the main thing the AI has been failing with, and as such has not been a focus so far but will likely be part of future updates :)

Second point:

The garrison order would grab the shittiest unit first, and then fill out with less shitty if it determined to need more divisions to cover the order, while the oposite is true for other order types. This is something I would like to spend more time on improving, but the intention is to concentrate weak forces in garrison orders and let the other orders grab the good ones first.
 
  • 3
Reactions:

SteelVolt

Technomancer
2 Badges
Aug 4, 2014
735
4.200
  • Paradox Order
  • Hearts of Iron IV Sign-up
This will seem incredibly vague I'm sure but has anything been done to address the German AI from going completely off the rails by 1940? We're talking things like declaring war on everyone it can all at once and inviting Finland into the Axis during the winter war thus starting a conflict with the Soviets early.

Apologies of I somehow missed a fix for this in proceeding diaries. Also apologies if that's going to be talked about later this week. I'm just getting antsy as this is my primary deal breaker. Right now I can't have a decent game of HoI4 unless I, myself, play as Germany. AI Germany is hopeless.

I have not seen the things you talk about happen in my over night hands offs for a very very long time (at least in historical mode), so unless you as a Finland player manage to join the Axis and drag Germany into an early war with Soviet Union, I think it is pretty safe to say that this area is much better.

That is not to say there might not be other thing you would consider "off the rails", as what is and isn't is subjective.
 
  • 4
  • 1
Reactions:

SteelVolt

Technomancer
2 Badges
Aug 4, 2014
735
4.200
  • Paradox Order
  • Hearts of Iron IV Sign-up
On this subject, are you per chance doing anything to split the garrison AI from the combat AI in the first place? As things are in 1.2, the AI pretty much repeatedly ruins its own plans, because whenever it decides to garrison area, it just grabs as many units as it deems needed from all over the place, which typically also means ongoing, active war fronts. So the front units wind up getting pulled away and strategically re-deployed half across continent, and then as soon as the movement ends they are sent back, because on the next re-evaluation the AI notices that hey, the fronts are now collapsing an/or understaffed. Cue another strategic re-deployment, and then every few weeks rinse, repeat. End effect: nothing ever gets effectively garrisoned, and the front operations are a mess.

Can't help but think the things would work far smoother if the countries had instead separate AI instance in addition to the current one, whose only area of responsibility/interest would be evaluating how many units are needed to garrison controlled areas, training units best suited for this task, and placing them in the relevant areas... working with unit pool completely separated from the regular army.

Depending on how you see it, it is already split up in a sense. But to do it as strict as you propose would be dangerous. Imagine a scenario where it would suddenly need to move 90% of the garrison units to the front in order to cover it, the AI would appear pretty damn stupid if it kept the garrison units in that order in stead of plugging the holes.
 
  • 3
  • 2
Reactions:

SteelVolt

Technomancer
2 Badges
Aug 4, 2014
735
4.200
  • Paradox Order
  • Hearts of Iron IV Sign-up
Nice DD!

I am curious on the encirclement detection:

Do you use flow networks to detract the potential bottleneck?
Out of my head I would guess you could use a sudden reduction in flow to front line provinces to lets say your capital as a predictor for an encirclement?
Short answer: no. As for how I have done it, I am sneakily going to sit on that as a trade secret ;)

Unfortunately I am not in a situationwhere I can take the time to go through a forum thread to verify if issues people are talking about are fixed. After release of 1.3, if there is anything you feel should have been fixed that you are unsure if it has been reported, I would encourage you to post about it on the bug forum :)
 
  • 5
  • 2
Reactions:

SteelVolt

Technomancer
2 Badges
Aug 4, 2014
735
4.200
  • Paradox Order
  • Hearts of Iron IV Sign-up
Can the AI decide to fabricate on other countries outside of focuses? It would be nice to see a brain behind that element of the game. My Understanding is that the ai just works through focuses, historical, in a certain order, and ahistorical in a random order.

Edit: Also can the AI build intelligently now? Like infrastructure in Africa if it has alot of units there.

Yes, it can fabricate outside of focuses. It has been able to to so for quite a while, but it will not do so just because more territory is nice, but because it thinks it will help its other war efforts. An AI the freely fabricates makes for very chaotic games.

The construction AI has gotten a couple of minor fixes, but will get more love in the future. More work has been put into production and deployment.
 
  • 2
Reactions:

SteelVolt

Technomancer
2 Badges
Aug 4, 2014
735
4.200
  • Paradox Order
  • Hearts of Iron IV Sign-up
Great Job Steelvolt, AI improvement is always welcome, can't wait to try out the AI. I have one question though, would the AI now occasionally halt advance when there are actually no enemy standing in front of? This is a problem that brother me a lot at the moment.

The AI can have a tendency to be a bit cautious about its planning bonus. It has not been given a proper overhaul, but I have tweaked it and it should be somewhat better now.
 
  • 2
Reactions:

SteelVolt

Technomancer
2 Badges
Aug 4, 2014
735
4.200
  • Paradox Order
  • Hearts of Iron IV Sign-up
@SteelVolt

Thanks for the DD and your work ... dont you think that the naval invasion target system should change ? i think not all coastal provinces should be suitable for invasion but only some of them (just like DH) ... imo that would be better for the ai and the human player ...

I see no reason in blocking the player from being able to invade badly. And even a seemingly poor invasion location can turn out to be an important step in the grander scheme of things.

When it comes to invasion AI, check back in tomorrow, when I intend to include some points about that ;)
 
  • 3
  • 1
Reactions: