Why does the AI still attack even if they are taking huge casualties and losing all battles?

  • 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.

PancuterM

Second Lieutenant
38 Badges
Dec 21, 2021
105
557
  • Crusader Kings II: Holy Fury
  • Crusader Kings II: Conclave
  • Europa Universalis IV: Mare Nostrum
  • Hearts of Iron IV: Cadet
  • Hearts of Iron IV: Together for Victory
  • Europa Universalis IV: Third Rome
  • Hearts of Iron IV: Death or Dishonor
  • Crusader Kings II: Jade Dragon
  • Hearts of Iron IV: Expansion Pass
  • Europa Universalis IV: Dharma
  • Europa Universalis IV: Cossacks
  • Europa Universalis IV: Golden Century
  • Hearts of Iron IV: Expansion Pass
  • Hearts of Iron IV: La Resistance
  • Battle for Bosporus
  • Europa Universalis 4: Emperor
  • Victoria 3 Sign Up
  • Hearts of Iron IV: By Blood Alone
  • Hearts of Iron IV: No Step Back
  • Europa Universalis IV: Art of War
  • Crusader Kings II: Charlemagne
  • Crusader Kings II: Legacy of Rome
  • Crusader Kings II: The Old Gods
  • Crusader Kings II: Rajas of India
  • Crusader Kings II: The Republic
  • Crusader Kings II: Sons of Abraham
  • Crusader Kings II: Sunset Invasion
  • Crusader Kings II: Sword of Islam
  • Europa Universalis IV
  • Crusader Kings II
  • Europa Universalis IV: Conquest of Paradise
  • Europa Universalis IV: Wealth of Nations
  • Europa Universalis IV: Call to arms event
  • Europa Universalis IV: Res Publica
  • Europa Universalis IV: El Dorado
  • Crusader Kings II: Way of Life
  • Europa Universalis IV: Common Sense
  • Crusader Kings II: Horse Lords
It's way too easy to defeat the AI by just letting them bleed manpower and infantry equipment by luring them into attacking your seemingly weaker defenses. Even if they are taking massive losses they will keep attacking. Why won't they just stop? This is one of the most frustrating things about playing against AI, yet at the same time it seems to be something easy to fix.

I was thinking that the AI could avoid this situation by:

a) Checking if their units are fully equipped or not, or if they have big equipment deficits. Based on this, they would take the decision of launching offensives or not. It's really simple. Nobody launches offensives if they don't have a material advantage. Nobody would ever launch an offensive if their units didn't even have enough equipment (well, maybe Putin). Anyways, HOI4 cannot grasp this yet, after like 6 years of release.

b) Checking the result of the last battles and deciding whether to attack or not based on how many casualties they took, or kill/death ratios. This one might be a bit trickier to implement. But it's definitely not something very hard to code.

So why hasn't this been done yet?
 
  • 7
  • 2Like
Reactions:

BeauNiddle

Lt. General
78 Badges
Oct 5, 2011
1.393
2.950
  • Stellaris: Galaxy Edition
  • Semper Fi
  • Europa Universalis IV: Res Publica
  • Tyranny: Gold Edition
  • Victoria 2: A House Divided
  • Leviathan: Warships
  • Victoria 2: Heart of Darkness
  • Heir to the Throne
  • Hearts of Iron III: Their Finest Hour
  • Hearts of Iron III
  • For the Motherland
  • Europa Universalis IV: Wealth of Nations
  • Europa Universalis IV: Conquest of Paradise
  • Divine Wind
  • Europa Universalis III Complete
  • Tyranny: Archon Edition
  • Tyranny: Archon Edition
  • Hearts of Iron IV: Colonel
  • Hearts of Iron IV: Cadet
  • Stellaris Sign-up
  • Hearts of Iron IV Sign-up
  • Hearts of Iron IV: Together for Victory
  • Stellaris: Digital Anniversary Edition
  • Stellaris: Leviathans Story Pack
  • 500k Club
  • Shadowrun: Dragonfall
  • BATTLETECH
  • Surviving Mars
  • Hearts of Iron IV: Death or Dishonor
  • Shadowrun Returns
  • Age of Wonders III
  • Tyranny - Bastards Wound
  • Europa Universalis III Complete
  • Hearts of Iron IV: No Step Back
  • Stellaris: Distant Stars
  • Stellaris: Apocalypse
  • Stellaris: Humanoids Species Pack
  • Europa Universalis IV
  • Shadowrun: Hong Kong
  • BATTLETECH - Digital Deluxe Edition
  • Europa Universalis III Complete
  • Hearts of Iron IV: Expansion Pass
  • Stellaris: Galaxy Edition
  • Victoria 2
  • Surviving Mars: Digital Deluxe Edition
  • Europa Universalis IV: El Dorado
  • Pillars of Eternity
  • Europa Universalis IV: Common Sense
  • Europa Universalis IV: Cossacks
  • Europa Universalis IV: Mare Nostrum
So why hasn't this been done yet?

To a certain extent it hasn't been done because it creates very static game play. Since all countries can keep producing divisions (and because the AI is bad at creating spearheads) all that will happen is that every border will end up with hundreds of troops guarding it and nobody doing anything. It makes the game super dull and a turn off for new players.

That said there are still a lot of improvements they could make to the system without bogging it down (I think) so hopefully Paradox will tweak it every so often.
 
  • 6
  • 1Like
Reactions:

bitmode

1st Reverse Engineer Battalion
Nov 10, 2016
3.789
6.888
I was thinking that the AI could avoid this situation by:

a) Checking if their units are fully equipped or not, or if they have big equipment deficits. Based on this, they would take the decision of launching offensives or not. It's really simple.
By and large, the devs follow that same line of thinking, but it is not that simple. You can try out your specific idea by changing a few defines:
Code:
ORG_UNIT_STRONG = 0.75,						-- Organization % for unit to be considered strong
STR_UNIT_STRONG = 0.75,						-- Strength (equipment) % for unit to be considered strong

ORG_UNIT_WEAK = 0.15,						-- Organization % for unit to be considered weak
STR_UNIT_WEAK = 0.2,						-- Strength (equipment) % for unit to be considered weak

ORG_UNIT_NORMAL = 0.35,						-- Organization % for unit to be considered normal
STR_UNIT_NORMAL = 0.4,						-- Strength (equipment) % for unit to be considered normal

PLAN_FACTION_STRONG_TO_EXECUTE = 0.50,		-- % or more of units in an order to consider executing the plan
PLAN_FACTION_NORMAL_TO_EXECUTE = 0.65,		-- % or more of units in an order to consider executing the plan
PLAN_FACTION_WEAK_TO_ABORT = 0.65,			-- % or more of units in an order to consider executing the plan
But after you have tuned those values to the situation you are thinking of right now, you'll find that the AI is too passive in other situations.
 
  • 10
Reactions:

Sbrubbles

Colonel
17 Badges
Jan 6, 2014
1.021
2.319
  • Victoria 2: A House Divided
  • Victoria 2: Heart of Darkness
  • Stellaris
  • Hearts of Iron IV: No Step Back
  • Hearts of Iron IV: La Resistance
  • Age of Wonders: Planetfall
  • Hearts of Iron IV: Expansion Pass
  • Hearts of Iron IV: Expansion Pass
  • Hearts of Iron IV: Death or Dishonor
  • Hearts of Iron IV: Together for Victory
  • Hearts of Iron IV: Cadet
  • Europa Universalis IV
  • Pillars of Eternity
  • Victoria 2
  • Victoria: Revolutions
  • Europa Universalis IV: Res Publica
  • Europa Universalis IV: Wealth of Nations
I remember someone comenting that at some point the AI indeed had more reasonable calculations when deciding to attack, but this was purpusefully changed because it often led to passive AI and players found the passive AI boring.

Sorry about the vagueness, this likely happened way before I got into the game.
 

TheMeInTeam

Field Marshal
54 Badges
Dec 27, 2013
30.231
18.879
  • Age of Wonders III
  • Crusader Kings II: Conclave
  • Hearts of Iron IV: No Step Back
  • Stellaris
  • Hearts of Iron IV: Cadet
  • Crusader Kings II: Reapers Due
  • Europa Universalis IV: Rights of Man
  • Hearts of Iron IV: Together for Victory
  • Crusader Kings II: Monks and Mystics
  • Europa Universalis IV: Mandate of Heaven
  • Europa Universalis 4: Emperor
  • Hearts of Iron IV: Death or Dishonor
  • Stellaris: Synthetic Dawn
  • Europa Universalis IV: Cossacks
  • Europa Universalis IV: Cradle of Civilization
  • Battle for Bosporus
  • Hearts of Iron IV: Expansion Pass
  • Europa Universalis IV: Rule Britannia
  • Europa Universalis IV: Dharma
  • Crusader Kings II: Holy Fury
  • Europa Universalis IV: Golden Century
  • Hearts of Iron IV: Expansion Pass
  • Prison Architect
  • Hearts of Iron IV: La Resistance
  • Crusader Kings III
  • Crusader Kings II: Horse Lords
  • Europa Universalis IV: Common Sense
  • Magicka 2
  • Crusader Kings II: Way of Life
  • Europa Universalis IV: El Dorado
  • Victoria 2
  • Europa Universalis IV
  • Crusader Kings II: Charlemagne
  • Crusader Kings II
  • Crusader Kings II: Legacy of Rome
  • Crusader Kings II: The Old Gods
  • Crusader Kings II: Rajas of India
  • Crusader Kings II: The Republic
  • Crusader Kings II: Sons of Abraham
  • Crusader Kings II: Sunset Invasion
  • Crusader Kings II: Sword of Islam
  • Europa Universalis IV: Art of War
  • Europa Universalis IV: Conquest of Paradise
  • Europa Universalis IV: Wealth of Nations
  • Hearts of Iron III
  • Magicka
  • Europa Universalis IV: Res Publica
  • Stellaris - Path to Destruction bundle
  • Victoria 2: A House Divided
  • Victoria 2: Heart of Darkness
You'd probably get more mileage from making front lines more functional and teaching AI to use them. Max planning with okay-ish divisions concentrating on specific spots in a line hurts, but the AI is poor at it and front lines are extremely inefficient at doing it compared to micro. Narrow that gap, and it should make AI combat more dangerous.
 
  • 4
  • 1
Reactions:

kaguravitro

General
63 Badges
Mar 4, 2015
2.385
478
  • Hearts of Iron IV: No Step Back
  • Hearts of Iron IV: By Blood Alone
  • Stellaris: Nemesis
  • Europa Universalis IV: Call to arms event
  • Stellaris: Necroids
  • Stellaris: Lithoids
  • Cities: Skylines - Parklife
  • Stellaris: Humanoids Species Pack
  • Stellaris: Digital Anniversary Edition
  • Stellaris: Galaxy Edition
  • Stellaris: Galaxy Edition
  • Stellaris: Leviathans Story Pack
  • Cities: Skylines - Mass Transit
  • Europa Universalis IV: Mandate of Heaven
  • Stellaris: Synthetic Dawn
  • Cities: Skylines - Green Cities
  • Europa Universalis IV: Cradle of Civilization
  • Stellaris: Apocalypse
  • Europa Universalis IV: Rights of Man
  • Stellaris: Distant Stars
  • Europa Universalis IV: Dharma
  • Cities: Skylines Industries
  • Stellaris: Megacorp
  • Europa Universalis IV: Golden Century
  • Hearts of Iron IV: Expansion Pass
  • Stellaris: Ancient Relics
  • Stellaris: Federations
  • Battle for Bosporus
  • Europa Universalis 4: Emperor
  • Divine Wind
  • Europa Universalis IV: Art of War
  • Europa Universalis IV: Wealth of Nations
  • Hearts of Iron III
  • Europa Universalis IV: Res Publica
  • Victoria: Revolutions
  • Semper Fi
  • Arsenal of Democracy
  • Victoria 2: A House Divided
  • Cities: Skylines
  • Europa Universalis III: Collection
  • Europa Universalis IV: El Dorado
  • Europa Universalis IV: Common Sense
  • Cities: Skylines - After Dark
  • Europa Universalis IV: Cossacks
  • Europa Universalis IV: Mare Nostrum
2 reasons, high valuess for ai battle plan settings in defines, astronomical defense/entrench values, it's impossible not to grind even to the player.
I agree that fronts needs to grid a but but with this values you are getting a cow in the meat grinder
 

PancuterM

Second Lieutenant
38 Badges
Dec 21, 2021
105
557
  • Crusader Kings II: Holy Fury
  • Crusader Kings II: Conclave
  • Europa Universalis IV: Mare Nostrum
  • Hearts of Iron IV: Cadet
  • Hearts of Iron IV: Together for Victory
  • Europa Universalis IV: Third Rome
  • Hearts of Iron IV: Death or Dishonor
  • Crusader Kings II: Jade Dragon
  • Hearts of Iron IV: Expansion Pass
  • Europa Universalis IV: Dharma
  • Europa Universalis IV: Cossacks
  • Europa Universalis IV: Golden Century
  • Hearts of Iron IV: Expansion Pass
  • Hearts of Iron IV: La Resistance
  • Battle for Bosporus
  • Europa Universalis 4: Emperor
  • Victoria 3 Sign Up
  • Hearts of Iron IV: By Blood Alone
  • Hearts of Iron IV: No Step Back
  • Europa Universalis IV: Art of War
  • Crusader Kings II: Charlemagne
  • Crusader Kings II: Legacy of Rome
  • Crusader Kings II: The Old Gods
  • Crusader Kings II: Rajas of India
  • Crusader Kings II: The Republic
  • Crusader Kings II: Sons of Abraham
  • Crusader Kings II: Sunset Invasion
  • Crusader Kings II: Sword of Islam
  • Europa Universalis IV
  • Crusader Kings II
  • Europa Universalis IV: Conquest of Paradise
  • Europa Universalis IV: Wealth of Nations
  • Europa Universalis IV: Call to arms event
  • Europa Universalis IV: Res Publica
  • Europa Universalis IV: El Dorado
  • Crusader Kings II: Way of Life
  • Europa Universalis IV: Common Sense
  • Crusader Kings II: Horse Lords
By and large, the devs follow that same line of thinking, but it is not that simple. You can try out your specific idea by changing a few defines:

But after you have tuned those values to the situation you are thinking of right now, you'll find that the AI is too passive in other situations.
So maybe the second option would work better? As in making the AI check the result of battles in that front in the last months to decide whether it's worth it to attack or not. It seems to be a bit more dynamic, and after some months have passed they would try again and see if it works. If it doesn't they stop and wait for a few months to try again. That way they won't completely stop trying to breakthrough, but they won't do suicide attacks neither
 

kaguravitro

General
63 Badges
Mar 4, 2015
2.385
478
  • Hearts of Iron IV: No Step Back
  • Hearts of Iron IV: By Blood Alone
  • Stellaris: Nemesis
  • Europa Universalis IV: Call to arms event
  • Stellaris: Necroids
  • Stellaris: Lithoids
  • Cities: Skylines - Parklife
  • Stellaris: Humanoids Species Pack
  • Stellaris: Digital Anniversary Edition
  • Stellaris: Galaxy Edition
  • Stellaris: Galaxy Edition
  • Stellaris: Leviathans Story Pack
  • Cities: Skylines - Mass Transit
  • Europa Universalis IV: Mandate of Heaven
  • Stellaris: Synthetic Dawn
  • Cities: Skylines - Green Cities
  • Europa Universalis IV: Cradle of Civilization
  • Stellaris: Apocalypse
  • Europa Universalis IV: Rights of Man
  • Stellaris: Distant Stars
  • Europa Universalis IV: Dharma
  • Cities: Skylines Industries
  • Stellaris: Megacorp
  • Europa Universalis IV: Golden Century
  • Hearts of Iron IV: Expansion Pass
  • Stellaris: Ancient Relics
  • Stellaris: Federations
  • Battle for Bosporus
  • Europa Universalis 4: Emperor
  • Divine Wind
  • Europa Universalis IV: Art of War
  • Europa Universalis IV: Wealth of Nations
  • Hearts of Iron III
  • Europa Universalis IV: Res Publica
  • Victoria: Revolutions
  • Semper Fi
  • Arsenal of Democracy
  • Victoria 2: A House Divided
  • Cities: Skylines
  • Europa Universalis III: Collection
  • Europa Universalis IV: El Dorado
  • Europa Universalis IV: Common Sense
  • Cities: Skylines - After Dark
  • Europa Universalis IV: Cossacks
  • Europa Universalis IV: Mare Nostrum
So maybe the second option would work better? As in making the AI check the result of battles in that front in the last months to decide whether it's worth it to attack or not. It seems to be a bit more dynamic, and after some months have passed they would try again and see if it works. If it doesn't they stop and wait for a few months to try again. That way they won't completely stop trying to breakthrough, but they won't do suicide attacks neither
It's dynamic, but the values force the grinder. The issue with lower values is that get stalemate fronts than need reinforces to be break. Devs don't like it, even if it's better with their flows.
At the end I'm much inclined to think that a better calculation for the dispersion of troops over the fronts and garrison duty should let lower values and not get frizzed fronts. Also have reserved units, real units to swap should help no only to defend but to balance the effect in streching fronts.
Also lowering the reinforce speed helps a but with no fast refilled units in the fronts trying much prepend to grind.
 

bitmode

1st Reverse Engineer Battalion
Nov 10, 2016
3.789
6.888
I remember someone comenting that at some point the AI indeed had more reasonable calculations when deciding to attack, but this was purpusefully changed because it often led to passive AI and players found the passive AI boring.
I have three problems with this.

Firstly, compared to what the AI does now, actual WW2 was "boring". Sometimes nothing happened for weeks or months in places due to lack of offensive units, weather, re-supply etc. If the game functioned "perfectly" (if there was such a thing) it would indeed be more quiet to some extent. Not a bad thing in my opinion. Right now, with few exceptions, two AI armies facing each other will have at least one wanting to attack at any given time.

Secondly, despite what @podcat's signature says, reason is not just a nice-to-have. Imagine on-boarding a new developer to this mess or trying to backtrack why an innocent little change suddenly causes Germany to attack into the Maginot for the umpteenth time through some inadvertent interactions.

Lastly, the devs frequently say "we tried <minor variant of what we already have> and it did not improve the situation" when the crucial info is really "we are not willing to re-investigate our initial assumptions to substantially improve the system". Because it goes without saying that an AI can calculate reasonably while not being too passive. It would just have little in common with the current one.
So maybe the second option would work better?
I think your first idea is not all that bad. I'm sure you can easily find some improvements to be made there (and I think some large mods do change those defines). It's just not quite as trivial as "never attack if equipment is not full" and all is well. It needs some tinkering and testing because the algorithm behind it, well, sucks. I made a thread about it once, if I could find it.
As in making the AI check the result of battles in that front in the last months to decide whether it's worth it to attack or not. It seems to be a bit more dynamic, and after some months have passed they would try again and see if it works. If it doesn't they stop and wait for a few months to try again. That way they won't completely stop trying to breakthrough, but they won't do suicide attacks neither
A big problem to keep in mind when using historical data like this is how to invalidate it. I.e. you propose a few months of cooldown, which is a looong time for things to be changing. So the tricky part is often to identify the various scenarios that constitute significant change. Maybe the front moves a little or by a lot. Maybe the enemy withdraws some of their units (you can bet humans will, if you don't check), and so on. It's doable but quite an undertaking.
I would perhaps start a bit smaller and remember the combat capabilities of the enemy divisions. Knowing their hardness, soft attack, bonuses from generals etc. should allow for much more precise estimates of how the next battle will go.
Regardless, I would look at all of these options as just inputs into a more complex algorithm. If you just state "don't attack if <X>", it is almost guaranteed that a) a grognard will cite a historical battle where someone attacked despite <X> and b) a l33t gamer will remember a situation where attacking despite <X> was optimal.
 
  • 6Like
  • 2
  • 1Love
  • 1
Reactions:

The Colonel

Accursed metagamer
51 Badges
Jan 25, 2013
717
1.088
  • Hearts of Iron III: Their Finest Hour
  • Cities: Skylines Deluxe Edition
  • Victoria 2: Heart of Darkness
  • Victoria 2: A House Divided
  • Crusader Kings II
  • Semper Fi
  • Europa Universalis IV: Pre-order
  • Europa Universalis IV: Res Publica
  • Magicka
  • Hearts of Iron III
  • For the Motherland
  • Europa Universalis IV: Wealth of Nations
  • Europa Universalis IV: Conquest of Paradise
  • Europa Universalis IV: Art of War
  • Europa Universalis IV: Cradle of Civilization
  • Cities: Skylines - Parklife
  • Europa Universalis IV: Dharma
  • Europa Universalis IV: Rule Britannia
  • Stellaris: Apocalypse
  • Hearts of Iron IV: Expansion Pass
  • Crusader Kings III: Royal Edition
  • Hearts of Iron IV: Death or Dishonor
  • Europa Universalis IV: Mandate of Heaven
  • Europa Universalis IV: Golden Century
  • Hearts of Iron IV: Expansion Pass
  • Hearts of Iron IV: La Resistance
  • Crusader Kings III
  • Stellaris
  • Battle for Bosporus
  • Europa Universalis 4: Emperor
  • Hearts of Iron IV: By Blood Alone
  • Hearts of Iron IV: No Step Back
  • Europa Universalis IV: Cossacks
  • Europa Universalis IV
  • Victoria 2
  • 500k Club
  • Europa Universalis IV: El Dorado
  • Magicka 2
  • Europa Universalis IV: Common Sense
  • Hearts of Iron IV: Together for Victory
  • Europa Universalis IV: Mare Nostrum
  • Stellaris: Galaxy Edition
  • Hearts of Iron IV: Cadet
  • Hearts of Iron IV: Colonel
  • Europa Universalis IV: Rights of Man
  • Stellaris: Galaxy Edition
  • Hearts of Iron IV Sign-up
  • Cities: Skylines
  • Europa Universalis IV: Third Rome
  • Victoria: Revolutions
2 reasons, high valuess for ai battle plan settings in defines, astronomical defense/entrench values, it's impossible not to grind even to the player.
I agree that fronts needs to grid a but but with this values you are getting a cow in the meat grinder
I mean it's the only thing that causes ww2-level casualties in the game's simulation tbh. Playing well with tanks, you can cap the soviets with <100k casualties if you don't get lazy and battleplan by the end. Even without tanks, strong infantry with overwhelming air cover can battleplan them to death for like 500k casualties. Would be kinda silly if the AI sat around never using its manpower.

Not that I'm a big history/simulation > gameplay person, but some things are quite silly and not necessary for a good time. Unfortunately I think the only solution to approaching realistic man and material losses would be greatly increasing the losses from short combats, which would then require increasing production rates substantially which would then allow players to deploy way more troops and run rings around the AI. And getting supply and other costs to the level to constrain this would seriously dampen fun factor.
 

mineralko

Private
2 Badges
Sep 3, 2015
19
52
  • Hearts of Iron IV: Cadet
  • Crusader Kings II
Lastly, the devs frequently say "we tried <minor variant of what we already have> and it did not improve the situation" when the crucial info is really "we are not willing to re-investigate our initial assumptions to substantially improve the system". Because it goes without saying that an AI can calculate reasonably while not being too passive. It would just have little in common with the current one.

This annoys me to no end - there's just no way to fix the algorithm by twiddling the values, the algorithm itself is the problem - in positioning, in attack, in defense (there isn't any...). Funny thing, inability to simulate strategic though to any satisfactory level was recognized, and we have game mechanics to deal with it (focci), but for some reason land war is deemed good enough (it's not).
 
  • 1
  • 1
Reactions:

Jays298

Lt. General
16 Badges
Mar 21, 2011
1.387
2.199
  • Crusader Kings II
  • Europa Universalis: Rome
  • Rome Gold
  • Rome: Vae Victis
  • Cities: Skylines
  • Stellaris
  • Hearts of Iron IV: Cadet
  • Hearts of Iron IV: Together for Victory
  • Hearts of Iron IV: Death or Dishonor
  • Hearts of Iron IV: Expansion Pass
  • Hearts of Iron IV: Expansion Pass
  • Hearts of Iron IV: La Resistance
  • Battle for Bosporus
  • Hearts of Iron IV: By Blood Alone
  • Hearts of Iron IV: No Step Back
  • Imperator: Rome
You are aware of all the stupid operations the soviets did betweeen 41 and 43 right?
Not really. In school I couldn't make it thru the book Battle of Kursk.

Even if that's historically what they did (and I'm sure the Germans had their blunders too), in a game we have entrenchment as a mechanic that is not being properly used if AI attacks when it should be defending.

So much so that vs AI, just wait for them to attack, then you attack de'org'd troops with minimal entrenchment.