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!

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.

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.

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.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.- AI is no longer using all types of garrison locations.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.