Hearts of Iron IV’s AI is so good, the devs sometimes need to handicap it via code

An alt-history path for Poland in Hearts of Iron 4

Hearts of Iron IV is a grand strategy game that attempts to offer the ultimate World War 2 sandbox. Through historical and plausible alt-history options, it allows you – in each individual game – to fight your own version of the Second World War, and tell your own stories of an alternative greatest generation.

But with the player taking charge of only one out of dozens nations that existed in 1936, making sure the rest of the world behaves in a manner that facilitates an engaging and believable narrative is an on-going struggle. In many cases, the developers have intervened directly; it seems the UK was so good at beating Italy in North Africa, for example, the team had to hard-code a solution that rendered them less effective.

Reddit user drefvelin on the Hearts of Iron IV subreddit discovered a line of code while looking at the AI files for a mod they are creating, called “ENG_please_stop_stomping_italy_so_hard_in_africa_ty”. The gist of the code ensures that Great Britain and any dominions (if controlled by the AI) don’t put too many troops into North Africa to ensure that the Italian AI has a fighting chance of winning the theatre. “These kinds of AI directives are usually there for a few reasons… [for instance] to control pacing,” Hearts of Iron IV game director Dan Lind tells us.

“Africa wasn’t prioritised by either side. So if the game AI has one main front it will naturally get focus. Ideally, you want it to drag the war out and not conclude too early. Prolonging the North Africa campaign allows that.”

TIL that the italian AI in North Africa sucks so bad the british AI is coded to at least give Italy a chance… from hoi4

There are other reasons for coding in a guiding hand as well. Lind tells us that the UK AI specifically tends to overestimate its naval defence strength, so without some kind of intervention it would often overcommit forces to overseas theatres, and then succumb to naval invasions from France.

Lind also explains how all of the game’s different AI drivers draw from the same “brains”, so coding in specific direction also lets the team “add some character in how [the AI] prioritises certain theatres.”

“We tend to like funny and extreme AI strategy names,” Lind concludes, and this also seems to extend to developer notes as Reddit user StozefJalin discovered.

Hearts of Iron IV Buy Now Hearts of Iron IV StrategyMilitaryBuy Now

In other news, the development team has put out a new dev diary that continues from last weeks’, this time looking at some of the ‘alt-history’ options for the Soviet Union. Most of the Soviet Union’s alternatives are focused on left-wing politics, and now the player can now explore some of the other flavours of communism that floated around before Stalin enforced his own particular brand.

Hearts of Iron IV is gearing up towards a new expansion – No Step Back – and another major patch, neither of which currently has a release window.

{"schema":{"page":{"content":{"headline":"Hearts of Iron IV\u2019s AI is so good, the devs sometimes need to handicap it via code","type":"news","category":"hearts-of-iron-iv"},"user":{"loginstatus":false},"game":{"publisher":"Paradox Interactive","genre":"Strategy Gamer","title":"Hearts of Iron IV","genres":["Strategy Gamer","Simulation"]}}}}