AI abandoning its own country and sends troops off to siege down far away, unimportant land.

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

Vampiresoap

Lt. General
34 Badges
May 4, 2011
1.276
1.003
  • Imperator: Rome
  • Hearts of Iron IV: Death or Dishonor
  • Stellaris: Synthetic Dawn
  • Cities: Skylines - Green Cities
  • Hearts of Iron IV: Expansion Pass
  • Stellaris: Humanoids Species Pack
  • Stellaris: Apocalypse
  • Stellaris: Distant Stars
  • Stellaris: Megacorp
  • Stellaris - Path to Destruction bundle
  • Prison Architect
  • Stellaris: Ancient Relics
  • Stellaris: Lithoids
  • Stellaris: Federations
  • Crusader Kings III
  • Stellaris: Necroids
  • Hearts of Iron IV: No Step Back
  • Hearts of Iron IV: Together for Victory
  • Europa Universalis IV
  • Victoria 2
  • Victoria 2: A House Divided
  • Victoria 2: Heart of Darkness
  • Cities: Skylines
  • Cities: Skylines Deluxe Edition
  • Cities: Skylines - After Dark
  • Stellaris
  • Stellaris: Galaxy Edition
  • Stellaris: Galaxy Edition
  • Stellaris: Galaxy Edition
  • Hearts of Iron IV: Cadet
  • Stellaris: Digital Anniversary Edition
  • Stellaris: Leviathans Story Pack
  • Crusader Kings II
  • Crusader Kings II: The Old Gods
And what exactly would you do if outnumbered 30k vs 100k? Assuming, of course, that your enemy is not utterly inferior at warfare or tech/ideas.

I'm definitely mediocre at EU4 warfare, but seeking battles against a stronger foe doesn't seem like a promising strategy. Siege racing and harrassing to provoke a milder peace treaty where my armies and manpower aren't wiped out seems just better to me in the long run. Or concede a minor loss near-instantly. Since the AI won't to the latter, and pretty much attempts the former, I'd like to hear what you want it to do differently (rather than just better)

I would suggest watching good youtubers defend their territories to initiate you into guerrilla warfare in EU4.

A few important points when defending:

1. If you can siege faster than your opponent, like having a lot of artillery, then you can basically run circles around them.

2. You CAN win against overwhelming numbers, especially when you have the right ideas and techs.

3. The AI's split up their troops constantly. For example, in a 30k vs. 90k scenario, you'll not be fighting against a 90k stack, you'd be fighting three 30k stacks. So ambush lone stacks while they're in plain terrain. In this case, you actually have the upper hand because presumably it's 30k elite troops vs. 30k peasants (when you satisfy point 2).

And no, sieging far away unimportant lands is never a valid response to overwhelming enemy forces, nor is it in any way reasonable.
 
  • 2Like
Reactions:

Ruian

Lt. General
30 Badges
Nov 17, 2018
1.682
368
  • Europa Universalis IV: El Dorado
  • Europa Universalis 4: Emperor
  • Europa Universalis IV: Golden Century
  • Europa Universalis IV: Dharma
  • Europa Universalis IV: Rule Britannia
  • Europa Universalis IV: Cradle of Civilization
  • Europa Universalis IV: Mandate of Heaven
  • Europa Universalis IV: Rights of Man
  • Crusader Kings II: Conclave
  • Europa Universalis IV: Cossacks
  • Crusader Kings II: Horse Lords
  • Europa Universalis IV: Common Sense
  • Crusader Kings II: Way of Life
  • Europa Universalis IV
  • Europa Universalis IV: Mare Nostrum
  • 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
  • Europa Universalis IV: Third Rome
  • Crusader Kings II: Sons of Abraham
  • Crusader Kings II: Sunset Invasion
  • Europa Universalis IV: Call to arms event
  • Crusader Kings II: Sword of Islam
  • Europa Universalis IV: Art of War
  • Europa Universalis IV: Conquest of Paradise
  • Europa Universalis IV: Wealth of Nations
  • Crusader Kings II
  • Europa Universalis IV: Res Publica
Maybe the real problem is that in EU4 it is impossible to win when outnumbered. Maybe troops have a bonus (5%? 10%?) fighting inside their borders?
This is not even close to true.

The World Conquest crowd will be displeased as always as this would make conquests harder, like they were in real life...
On the contrary, I haven't played in months because the game is too easy. It just isn't fun when the AI presents zero challenge. I want them to hire far over forcelimit, bankruptcy war, scorch earth, flank me from 3 directions, hire condotierri behind me, dogpile me, merge into death stacks, etc.

The casual crowd will be displeased since the game would be too hard, but that's real life.
 

sekelsenmat

Colonel
22 Badges
Aug 10, 2009
889
937
  • Europa Universalis IV: Rights of Man
  • Hearts of Iron IV: La Resistance
  • Hearts of Iron IV: Expansion Pass
  • Cities: Skylines Industries
  • Europa Universalis IV: Dharma
  • Europa Universalis IV: Rule Britannia
  • Hearts of Iron IV: Expansion Pass
  • Stellaris: Synthetic Dawn
  • Hearts of Iron IV: Death or Dishonor
  • Europa Universalis IV: Third Rome
  • Hearts of Iron IV: Together for Victory
  • Hearts of Iron IV: Cadet
  • Stellaris
  • Europa Universalis IV: Mare Nostrum
  • Europa Universalis IV: Cossacks
  • Cities: Skylines - After Dark
  • Europa Universalis IV: El Dorado
  • Cities: Skylines
  • Europa Universalis IV
  • Crusader Kings II
  • Europa Universalis IV: Art of War
  • Crusader Kings II: Sword of Islam
On the contrary, I haven't played in months because the game is too easy. It just isn't fun when the AI presents zero challenge. I want them to hire far over forcelimit, bankruptcy war, scorch earth, flank me from 3 directions, hire condotierri behind me, dogpile me, merge into death stacks, etc.

The casual crowd will be displeased since the game would be too hard, but that's real life.

Really? I am playing as Russia, defeated PLC right at the start and took Smolensk, also took Kazan, Crimea, Astrakhan, Novgorod, cored everything. But I'm in permanent debt, fought 4 wars Vs Ottomans to weaken them. It's 1550 and PLC declares on me. I have 40k troops and on debt, they have 80k? I wonder from where the AI has so much money.... maybe I'll win cause I have Sweden and Austria on my side, but I was left with the impression the AI plays better than me. It kind of annoys me the AI only declares on weak countries and on me....so the world moves to a few huge blobs
 

Tempscire

First Lieutenant
24 Badges
Mar 4, 2018
298
472
  • Europa Universalis IV: Art of War
  • Europa Universalis IV: Wealth of Nations
  • Europa Universalis IV: Third Rome
  • Stellaris
  • Europa Universalis 4: Emperor
  • Imperator: Rome
  • Imperator: Rome Deluxe Edition
  • Europa Universalis IV: Golden Century
  • Europa Universalis IV: Dharma
  • Europa Universalis IV: Rule Britannia
  • Europa Universalis IV: Cradle of Civilization
  • Age of Wonders III
  • Europa Universalis IV: Mandate of Heaven
  • Europa Universalis IV: Rights of Man
  • Europa Universalis IV: Mare Nostrum
  • Europa Universalis IV: Cossacks
  • Europa Universalis IV: Common Sense
  • Pillars of Eternity
  • Europa Universalis IV: El Dorado
  • Europa Universalis IV: Conquest of Paradise
  • Europa Universalis IV
  • Crusader Kings II
  • Europa Universalis IV: Res Publica
  • Magicka
I will try to give a somewhat comprehensible answer to the question why the AI does flee this much and how one might fix such behaviour:
First one needs to understand how the EU4 combat AI works:
Every stack (i.e. a certain number of units merged together) assigns a number to each province and the lower the number is the more the stack wants to go to the province. This number depends on a variety of factors like distance and enemy troops and can be seen by using the command mapmode aieval in the console. I do not want to go into detail on all the available factors but rather focus on the one most important for this behaviour, which is threat or acceptable balance:
The idea is the following again the AI assigns to every a number to every province which now depends on the estimated strength of enemy and allied regiments nearby and if the number is too high (i.e. the enemy is estimated to be stronger than the allied troops) then the stack does not want to move to the province in almost any circumstance. This completely negates all other modifiers and can completely block the AI from moving troops in a certain area if outmatched.
In detail this works like this: Every stack gets assigned two numbers to every province. First the threat which will be discussed in detail later and second a number depending on how good/bad the province is for a fight depending on terrain bonuses etc. (The higher this is the better) Then it divides the threat by the second number and compares it to a defined number ACCEPTABLE_BALANCE_DEFAULT which is normally set to 1.7 and is one of the few modifiable aspects of EU4 combat. If the Quotient is larger than ACCEPTABLE_BALANCE_DEFAULT^(-1) the AI deems the province too dangerous to enter.

20200205184829_1.jpg

In this example Ramazan fights against the Ottomans and while it would like to siege down Anatolia it is too scared to do so (the provinces in red) for example in one province the AI estimates the Ottomans to be 23.10 times stronger than Ramazan and therefore wants to avoid combat at any cost and rather go to the other side of the strait to siege down the Ottoman hinterlands if it can do so.
Now we want to look at the way the threat is calculated and which problems arise from this:
As with the AI evaluation there is also a mapmode which allows to see the assigned threat which is mapmode aithreateval. From there one can deduce the formula used to calculate threat (with the necessary mathematical abilities at least ) and I want to give a quick summary of its most important aspects:
1) The formula calculates two numbers, enemy strength and allied strength and divides them,
2) The AI simulates a scenario where all troops except the selected stack are in the same position they are in right now and the selected stack is in the province for which the threat is calculated,
3) It takes into account all enemy/allied troops which are 4 or less provinces away,
4) It depends on troop quality, distance to the province and number of troops and nothing else ( most importantly not on combat width, flanking range and distribution of unit types),
5) The troop quality estimation is decent (it has some exploitable weaknesses as bankrupt horde players might know) it could be improved slightly but I wont go into detail here,
6) The distance function is a factor 10^(1-D/4) where D is the distance in number of provinces,
7) The formula is quadratic in the number of troops.

Some things to take away from these points:
2) The AI has a tendency to build small stacks, these are heavily disfavored by the formula as a large stack is far more influential when moved to another position. Therefore larger stacks would benefit the AI greatly.
4) EU4 land combat depends heavily on the omitted variables especially CW which I will demonstrate later.
7) This is the most problematic part, as EU4 land combat is only in rare circumstances quadratic in troop number, which the following examples will show:

Example 1 (CW infinite, Flanking range 1)
3 Infantry vs 1 Infantry (Strength 1)
Here quadratic is indeed the right estimate as the three regiments deal 3 times the damage and can suffer 3 times the casualties which yields 3*3=3^2=9.
With a bit of mathematical knowledge this yields: A version of the EU4 combat system with infinite CW, infinite flanking range and no backrow is indeed quadratic in the number of troops, which implies that the currently used strength estimate is true for such a system.

Example 2 (CW infinite, Flanking range 1)
20 Infantry vs 1 Infantry (Strength 1)
Here the 20 Infantry can sustain 20 times the damage but only 3 can attack which yields a strength comparison of 3*20=60 opposed to the 20^2=400 the current formula yields which leads to a vast overestimation of the higher troop number ( a recurring theme with the current formula as it indeed is an upper bound of the correct strength estimation).

Example 3 (CW 20, Flanking range arbitrary)
40 Infantry vs 20 Infantry (Strength 1)
If you know EU4 combat well enough you know that this battle will be an exact draw (due to the backline morale damage). Note that here the strength is sub-linear in the amount of troops which is far away from quadratic. (Strength = 1 vs 2^2 = 4 with the current formula)

Example 4 (CW 20, Flanking range arbitrary) Perfect Reinforcement
40 Infantry vs 20 Infantry (Strength 1)
Here the correct formula should be linear as the 40 are exactly twice as strong as the 20 also far away from quadratic. (Strength = 2 vs 2^2 = 4 with the current formula)
With a bit of mathematical knowledge this yields: A version of the EU4 combat system with infinite CW, no flanking range and no backrow is indeed linear in the number of troops, which is vastly different from the AI strength estimation.


These examples show that EU4 land combat is highly sub-quadratic (sometimes even sub-linear) and therefore a quadratic strength estimate (as currently implemented) vastly overestimates the strength of troop quantity which is at least to some degree responsible for the AI behaviour when outnumbered. But what can be changed about it in terms of a different strength evaluation formula. Here are two possibilities:
1) Keep the power law formula but make the (currently quadratic) exponent adjustable by defines. This would allow extensive testing of different versions, especially by AI modders (and there are a lot of very enthusiastic people out there who could do a lot of testing), or
2) Write a more accurate formula depending on CW (and possibly other factors). But this is not necessarily an easy task on the one hand on the theoretical side (this needs a post on its own and probably some valuable input of players very familiar with the combat system [for example the multiplayer community]) but also on the side of implementation ( the more parameters are involved the more clunky and probably slow everything gets).

Keep in mind that there are some exceptions to AI behaviour (for example if there are already ongoing battles that need to be reinforced) and that I omitted a decent amount of details in this post to keep it somewhat compact and readable. I hope I was moderately successful in doing the latter and this is helpful in understanding the problematic a bit better.
 
Last edited:
  • 7
  • 1Like
Reactions:

Ruian

Lt. General
30 Badges
Nov 17, 2018
1.682
368
  • Europa Universalis IV: El Dorado
  • Europa Universalis 4: Emperor
  • Europa Universalis IV: Golden Century
  • Europa Universalis IV: Dharma
  • Europa Universalis IV: Rule Britannia
  • Europa Universalis IV: Cradle of Civilization
  • Europa Universalis IV: Mandate of Heaven
  • Europa Universalis IV: Rights of Man
  • Crusader Kings II: Conclave
  • Europa Universalis IV: Cossacks
  • Crusader Kings II: Horse Lords
  • Europa Universalis IV: Common Sense
  • Crusader Kings II: Way of Life
  • Europa Universalis IV
  • Europa Universalis IV: Mare Nostrum
  • 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
  • Europa Universalis IV: Third Rome
  • Crusader Kings II: Sons of Abraham
  • Crusader Kings II: Sunset Invasion
  • Europa Universalis IV: Call to arms event
  • Crusader Kings II: Sword of Islam
  • Europa Universalis IV: Art of War
  • Europa Universalis IV: Conquest of Paradise
  • Europa Universalis IV: Wealth of Nations
  • Crusader Kings II
  • Europa Universalis IV: Res Publica
I'm curious. I know that this works but how does it work?
The short version is that the cavalry does so much damage in terms of raw casualties that the enemy's morale is irrelevant with 100% cav ratio, the +25% shock bonus hordes get and the natural 120% discipline hordes get (5 from horde unity, 5 from advisor and 10 [patch 1.28] from banners).

@Jarvin could probably explain the nitty gritty in terms of exactly why it works
 

Question

Field Marshal
Jun 11, 2019
2.831
5.726
Just look in the defines. In vanilla, the AI only fights battles if it has a 70% advantage or more. That means that it almost always avoids enemy stacks.

Setting it to 1 makes it better but the AI will still usually avoid your stacks.

The fact that the AI takes random ideas and almost never takes more than 1 policy doesnt help.
 
  • 1Like
Reactions:

EarlKonrad

Field Marshal
32 Badges
Jun 18, 2018
3.008
6.765
  • Magicka
  • Europa Universalis 4: Emperor
  • Europa Universalis IV: Dharma
  • Europa Universalis IV: Rule Britannia
  • Europa Universalis IV: Cradle of Civilization
  • BATTLETECH
  • Knights of Honor
  • Europa Universalis IV: Mandate of Heaven
  • Europa Universalis IV: Rights of Man
  • Europa Universalis IV: Cossacks
  • Europa Universalis IV: Common Sense
  • Mount & Blade: Warband
  • Europa Universalis IV: Pre-order
  • Europa Universalis IV: El Dorado
  • Europa Universalis IV
  • Divine Wind
  • Crusader Kings II: Legacy of Rome
  • Crusader Kings II: The Old Gods
  • Crusader Kings II: The Republic
  • Crusader Kings II: Sunset Invasion
  • Crusader Kings II: Sword of Islam
  • Europa Universalis IV: Third Rome
  • Europa Universalis III
  • Europa Universalis III: Chronicles
  • Heir to the Throne
  • Europa Universalis IV: Art of War
  • Europa Universalis IV: Conquest of Paradise
  • Europa Universalis IV: Wealth of Nations
  • Europa Universalis IV: Call to arms event
  • Europa Universalis IV: Res Publica
  • Crusader Kings II
  • The Kings Crusade
The short version is that the cavalry does so much damage in terms of raw casualties that the enemy's morale is irrelevant with 100% cav ratio, the +25% shock bonus hordes get and the natural 120% discipline hordes get (5 from horde unity, 5 from advisor and 10 [patch 1.28] from banners).

Got it.
 

Tempscire

First Lieutenant
24 Badges
Mar 4, 2018
298
472
  • Europa Universalis IV: Art of War
  • Europa Universalis IV: Wealth of Nations
  • Europa Universalis IV: Third Rome
  • Stellaris
  • Europa Universalis 4: Emperor
  • Imperator: Rome
  • Imperator: Rome Deluxe Edition
  • Europa Universalis IV: Golden Century
  • Europa Universalis IV: Dharma
  • Europa Universalis IV: Rule Britannia
  • Europa Universalis IV: Cradle of Civilization
  • Age of Wonders III
  • Europa Universalis IV: Mandate of Heaven
  • Europa Universalis IV: Rights of Man
  • Europa Universalis IV: Mare Nostrum
  • Europa Universalis IV: Cossacks
  • Europa Universalis IV: Common Sense
  • Pillars of Eternity
  • Europa Universalis IV: El Dorado
  • Europa Universalis IV: Conquest of Paradise
  • Europa Universalis IV
  • Crusader Kings II
  • Europa Universalis IV: Res Publica
  • Magicka
Just look in the defines. In vanilla, the AI only fights battles if it has a 70% advantage or more. That means that it almost always avoids enemy stacks.

Setting it to 1 makes it better but the AI will still usually avoid your stacks.

The fact that the AI takes random ideas and almost never takes more than 1 policy doesnt help.

Reading my post should probably clarify why this is not a particularly good solution ( as the AI's inaccuracies in strength estimation are far from being uniformly distributed among combat scenarios). When you lower this define you should also consider that this is an upper bound for a quotient for which the divisor (i.e. the number based on defensible terrain etc.) is set to 1.4 by default (i.e. for battles not impacted by terrain) therefore the 1.7 in defines actually corresponds to an estimation of an 1.7/1.4 ~ 20% advantage. Hence setting this to a number less than 1.4 results in the AI choosing battles where it is actually disfavored (at least the ones where the strength estimation is correct, for example if numbers are equal) which is less than desirable. Obviously one can not infer this from the defines alone which illustrates that just changing values without a proper understanding of the underlying mechanics might not be the best idea.

The short version is that the cavalry does so much damage in terms of raw casualties that the enemy's morale is irrelevant with 100% cav ratio, the +25% shock bonus hordes get and the natural 120% discipline hordes get (5 from horde unity, 5 from advisor and 10 [patch 1.28] from banners).

Yes that is roughly the idea. If the ratio of inflicted casualties to inflicted morale damage is far more skewed towards the casualties, (this happens mostly through a combination of negative morale modifiers [bankruptcy] and positive casualty modifiers [like discipline] and through the usage of cavalry) the low amount of troops on the opposing side will result in far less damage and therefore a relative diminution of the importance of morale modifiers. This is far more pronounced in the earlier stages of the game when artillery isn't as strong (as it does not take casualties). The AI does not consider this in its evaluation of troop quality as it just uses a formula weighting and multiplying different types of combat modifiers which does not simulate such a drastic change of combat behaviour and therefore does not "see" the diminished value of morale modifiers.
 

Ruian

Lt. General
30 Badges
Nov 17, 2018
1.682
368
  • Europa Universalis IV: El Dorado
  • Europa Universalis 4: Emperor
  • Europa Universalis IV: Golden Century
  • Europa Universalis IV: Dharma
  • Europa Universalis IV: Rule Britannia
  • Europa Universalis IV: Cradle of Civilization
  • Europa Universalis IV: Mandate of Heaven
  • Europa Universalis IV: Rights of Man
  • Crusader Kings II: Conclave
  • Europa Universalis IV: Cossacks
  • Crusader Kings II: Horse Lords
  • Europa Universalis IV: Common Sense
  • Crusader Kings II: Way of Life
  • Europa Universalis IV
  • Europa Universalis IV: Mare Nostrum
  • 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
  • Europa Universalis IV: Third Rome
  • Crusader Kings II: Sons of Abraham
  • Crusader Kings II: Sunset Invasion
  • Europa Universalis IV: Call to arms event
  • Crusader Kings II: Sword of Islam
  • Europa Universalis IV: Art of War
  • Europa Universalis IV: Conquest of Paradise
  • Europa Universalis IV: Wealth of Nations
  • Crusader Kings II
  • Europa Universalis IV: Res Publica
Hence setting this to a number less than 1.4 results in the AI choosing battles where it is actually disfavored (at least the ones where the strength estimation is correct, for example if numbers are equal) which is less than desirable.
I don't want to get too meta with history, but I don't really see a problem with this. A vast majority of battles fought in any given campaign are AI on AI. This makes the pathways from game to game pretty linear. The Ottomans will always beat the Mamluks (extreme edge cases excluded please guys).

Rather than looking at the AI's willingness to fight the player, I think the AI's willingness to fight itself should be a huge consideration. And I'd rather have the AI suiciding into me than what we have now. It would actually be more difficult because they would drain resources rather than just slowly delete troops until full annexation turned them into rebels.
 

Tempscire

First Lieutenant
24 Badges
Mar 4, 2018
298
472
  • Europa Universalis IV: Art of War
  • Europa Universalis IV: Wealth of Nations
  • Europa Universalis IV: Third Rome
  • Stellaris
  • Europa Universalis 4: Emperor
  • Imperator: Rome
  • Imperator: Rome Deluxe Edition
  • Europa Universalis IV: Golden Century
  • Europa Universalis IV: Dharma
  • Europa Universalis IV: Rule Britannia
  • Europa Universalis IV: Cradle of Civilization
  • Age of Wonders III
  • Europa Universalis IV: Mandate of Heaven
  • Europa Universalis IV: Rights of Man
  • Europa Universalis IV: Mare Nostrum
  • Europa Universalis IV: Cossacks
  • Europa Universalis IV: Common Sense
  • Pillars of Eternity
  • Europa Universalis IV: El Dorado
  • Europa Universalis IV: Conquest of Paradise
  • Europa Universalis IV
  • Crusader Kings II
  • Europa Universalis IV: Res Publica
  • Magicka
I don't want to get too meta with history, but I don't really see a problem with this. A vast majority of battles fought in any given campaign are AI on AI. This makes the pathways from game to game pretty linear. The Ottomans will always beat the Mamluks (extreme edge cases excluded please guys).

Rather than looking at the AI's willingness to fight the player, I think the AI's willingness to fight itself should be a huge consideration. And I'd rather have the AI suiciding into me than what we have now. It would actually be more difficult because they would drain resources rather than just slowly delete troops until full annexation turned them into rebels.
I definitely agree that the AI behaviour in AI vs AI wars is extremely important but I am not quite sure I understand what you are trying to say here. Would a more aggressive AI make pathways more or less linear and is this in your opinion desirable or not?

I also see some merit in increasing AI aggressiveness in general but the problem is that any "reasonable" change in the define will not be very large (for example the proposed change would be from 1.7 to 1, unless one is willing to almost completely remove the AI's evaluation by choosing something like 0.1 or so) and the threat evaluation produces far larger number like 10 (or 23.10 in the example picture above) if the AI is outnumbered and it does not change the AI behaviour whether it thinks it is outclassed by a factor of 10 or 10/1.7~6. Where this has an impact is when forces are a lot more even but then the AI threat evaluation is far more accurate which leads to the AI picking unnecessary and unfavorable battles even when actually having an advantage. An interesting idea could be a change in acceptable balance depending on how desperate a country is.
Regarding the idea of suiciding into the enemy, while I am not opposed to it in certain situations (which I also discussed in a thread you commented on
https://forum.paradoxplaza.com/foru...balance-calculation-and-combat-width.1323176/ )
I do not see how changing the acceptable balance improves the AI behaviour in that regard:

Some of the cases I can think of where picking losing battles seems justified are:
(i) You are severely outclassed and will lose anyway so the goal is to just inflict as much casualties as possible,
(ii) You are fighting a war of attrition and the opponent is running out of troops which means you can recover the WS and territory lost through the battles afterwards,
(iii) You are baiting the AI (or maybe another player) into canceling a siege.

The AI is (currently) just not equipped to distinguish if cases (ii) and (iii) apply, which does not depend on the acceptable balance, and the problem with (i) is that the evaluated threat numbers are so high that a factor of lets say 1.7 wont make a difference and therefore the change does not help in this scenario.

All in all I think reducing the define is decent but I would argue that something between 1.4 and 1.5 is far more reasonable than 1.0. But the real problem lies in the fact that the AI needs a far larger boost to aggressiveness in some cases than in others, this is just not doable by multiplying with a constant one needs to multiply it with a function (which is at least strictly decreasing in troop quantity).
 

Travis_Bickle

Colonel
27 Badges
Dec 30, 2012
1.050
2.567
  • Europa Universalis IV: Conquest of Paradise
  • Europa Universalis IV: Wealth of Nations
  • Europa Universalis IV: Res Publica
  • Europa Universalis III Complete
  • Hearts of Iron IV: Cadet
  • Europa Universalis 4: Emperor
  • Crusader Kings III: Royal Edition
  • Crusader Kings III
  • Europa Universalis IV: Golden Century
  • Europa Universalis IV: Dharma
  • Europa Universalis IV: Rule Britannia
  • Hearts of Iron IV: Expansion Pass
  • Europa Universalis IV: Cradle of Civilization
  • Hearts of Iron IV: Death or Dishonor
  • Europa Universalis IV: Third Rome
  • Europa Universalis IV: Mandate of Heaven
  • Hearts of Iron IV: Together for Victory
  • Europa Universalis IV: Rights of Man
  • Europa Universalis IV: Mare Nostrum
  • Europa Universalis IV: Cossacks
  • Europa Universalis IV: Common Sense
  • Europa Universalis IV: Pre-order
  • Europa Universalis IV: El Dorado
  • Europa Universalis III Complete
  • Europa Universalis III Complete
  • Europa Universalis IV: Art of War
  • Europa Universalis IV
The AI never seems to underestimate the player. They only declare wars on you they have a substantial numerical advantage.

I'd like it if I was declared on more often. Yeah the player would win more wars but it would also prove a drain on finances/manpower when you get declared on by nations you don't expect. Right now I can predict with 100% accuracy when I'm about to get a DoW.
 

Orioniys

First Lieutenant
24 Badges
Apr 17, 2013
273
282
  • Crusader Kings II
  • Magicka
  • Europa Universalis IV: Call to arms event
  • Cities in Motion 2
  • Crusader Kings II: Sword of Islam
  • Crusader Kings II: Sunset Invasion
  • Crusader Kings II: Sons of Abraham
  • Crusader Kings II: The Republic
  • Crusader Kings II: Rajas of India
  • Crusader Kings II: The Old Gods
  • Crusader Kings II: Legacy of Rome
  • Crusader Kings III: Royal Edition
  • Crusader Kings III
  • Imperator: Rome
  • Surviving Mars: Digital Deluxe Edition
  • Age of Wonders: Shadow Magic
  • Age of Wonders III
  • Surviving Mars
  • Hearts of Iron IV: Cadet
  • Stellaris
  • Europa Universalis IV: Pre-order
  • War of the Roses
  • Victoria 2
  • Europa Universalis IV
These examples show that EU4 land combat is highly sub-quadratic (sometimes even sub-linear) and therefore a quadratic strength estimate (as currently implemented) vastly overestimates the strength of troop quantity which is at least to some degree responsible for the AI behaviour when outnumbered. But what can be changed about it in terms of a different strength evaluation formula. Here are two possibilities:
1) Keep the power law formula but make the (currently quadratic) exponent adjustable by defines. This would allow extensive testing of different versions, especially by AI modders (and there are a lot of very enthusiastic people out there who could do a lot of testing), or
2) Write a more accurate formula depending on CW (and possibly other factors). But this is not necessarily an easy task on the one hand on the theoretical side (this needs a post on its own and probably some valuable input of players very familiar with the combat system [for example the multiplayer community]) but also on the side of implementation ( the more parameters are involved the more clunky and probably slow everything gets).
I guess as AI modder and MP player simultaneously I can give some feedback. But generally I think that part with threat calculations is probably the strongest part of the system.

The aspects I'm not happy about is;
- Lack of planning and preparations before the war even starts. It's not entirely Army movement problem, but AI can declare wars where he can't even naval invade the war target or not moved sufficient number of troops to the distant war theater in advance.
- AI evaluates too many regions and provinces, and does that too frequently. Which leads too chaotic movements and performance problems. From my experience running observer games on VH, wars between big colonizers and mainland great power can cause stuttering and diminish performance.
- Lack of troops coordination. Which is very important in big wars. Typically as force limits increase in MP, it's good idea to focus on one area or create big army groups. It can be one or two combat Army's and rest is Reserves.
- 1 stacks are an issues, it's typically a splinter or reinforcements. I assume they have special evaluations, but they can be easily picked off. If Ai is overwhelmed in a mid / late game they just sit still.

There is also aspect of how AI army movements are perceived by the player. And so far my impression is that restricting Ai army movements is the way to go.
My theory so far is that, excessive AI army movements especially simultaneously on several fronts is just not fun from a Players perspective. Tolerance to micro load is varied across the playerbase by a lot.
So the general idea is to make wars local if possible, and AI should operate from his home land prioritizing defence if it's necessary. Another way to phrase this would be, if it's a war between neighboring countries (no colonies involved) everything should be roughly on the same screen.
 
Last edited:
  • 1
  • 1
Reactions:

Laurent1944

Colonel
43 Badges
Oct 11, 2017
1.015
68
  • Crusader Kings II
  • Europa Universalis IV: Mare Nostrum
  • Europa Universalis IV: Third Rome
  • Stellaris: Apocalypse
  • Crusader Kings II: Reapers Due
  • Europa Universalis IV: Rights of Man
  • Stellaris: Leviathans Story Pack
  • Crusader Kings II: Monks and Mystics
  • Stellaris - Path to Destruction bundle
  • Europa Universalis IV: Mandate of Heaven
  • Stellaris: Synthetic Dawn
  • Europa Universalis IV: Cradle of Civilization
  • Stellaris
  • Europa Universalis IV: Rule Britannia
  • Stellaris: Distant Stars
  • Europa Universalis IV: Dharma
  • Stellaris: Megacorp
  • Europa Universalis IV: Golden Century
  • Imperator: Rome
  • Stellaris: Ancient Relics
  • Stellaris: Lithoids
  • Stellaris: Federations
  • Europa Universalis 4: Emperor
  • Crusader Kings II: Conclave
  • Europa Universalis IV: Cossacks
  • Crusader Kings II: Horse Lords
  • Europa Universalis IV: Common Sense
  • Crusader Kings II: Way of Life
  • Europa Universalis IV: El Dorado
  • Hearts of Iron IV: Cadet
  • Europa Universalis IV
  • Europa Universalis IV: Res Publica
  • Europa Universalis IV: Wealth of Nations
  • 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: Art of War
  • Europa Universalis IV: Conquest of Paradise
Interesting analysis of the AI system. One aditionnal weakness is to take in accounts all troops 4 provinces around, as time to travel between provinces may vary a lot depending of province size and other factors. The AI is certainly missing a lot of opportunities to score victories like that. To take in account the time to travel to the province, to fight and to retire will be more interesting.

On a strategic level, I guess that the AI is also not able to use its ships correctly, especially when it had naval supremacy and may easily block straits or move troops by sea far faster than by land (for example the Ottos with its mega galley fleet may easily ship troops everywhere in Med and Black Sea far faster than having then marching all the way). But the AI should then be taught to move its combat fleets and its transport fleets together to avoid disasters.

But the biggest problem for the AI is that it declares war without preparing them. A colonial power may declare on an Indian tribe with 0 troops on the hemisphere and a weak CN that will be conquered before the troops arrived. Such wars by the AI are far longer than by human players. An AI before going to war should do the check it does now (it and its allies vs the enemy and its allies) but also check if it has superiority in each region where they will be a fight.
 

Tempscire

First Lieutenant
24 Badges
Mar 4, 2018
298
472
  • Europa Universalis IV: Art of War
  • Europa Universalis IV: Wealth of Nations
  • Europa Universalis IV: Third Rome
  • Stellaris
  • Europa Universalis 4: Emperor
  • Imperator: Rome
  • Imperator: Rome Deluxe Edition
  • Europa Universalis IV: Golden Century
  • Europa Universalis IV: Dharma
  • Europa Universalis IV: Rule Britannia
  • Europa Universalis IV: Cradle of Civilization
  • Age of Wonders III
  • Europa Universalis IV: Mandate of Heaven
  • Europa Universalis IV: Rights of Man
  • Europa Universalis IV: Mare Nostrum
  • Europa Universalis IV: Cossacks
  • Europa Universalis IV: Common Sense
  • Pillars of Eternity
  • Europa Universalis IV: El Dorado
  • Europa Universalis IV: Conquest of Paradise
  • Europa Universalis IV
  • Crusader Kings II
  • Europa Universalis IV: Res Publica
  • Magicka
- Lack of planning and preparations before the war even starts. It's not entirely Army movement problem, but AI can declare wars where he can't even naval invade the war target or not moved sufficient number of troops to the distant war theater in advance.
But the biggest problem for the AI is that it declares war without preparing them. A colonial power may declare on an Indian tribe with 0 troops on the hemisphere and a weak CN that will be conquered before the troops arrived. Such wars by the AI are far longer than by human players. An AI before going to war should do the check it does now (it and its allies vs the enemy and its allies) but also check if it has superiority in each region where they will be a fight.
Yes this is very unfortunate and very bad for colonizers. But I think this should definitely be possible to implement as prior to 1.25 the AI actually did gather its troops at the border before declaring war. The most problematic here is probably the naval AI which has a lot of weaknesses and is less modifiable and more obscure than the land AI as it has less options for debugging like mapmodes. But recruiting mercenaries in a nearby owned province before the war should definitely be possible and very helpful.
- AI evaluates too many regions and provinces, and does that too frequently. Which leads too chaotic movements and performance problems. From my experience running observer games on VH, wars between big colonizers and mainland great power can cause stuttering and diminish performance.
I think the high frequency of evaluation is unfortunately necessary as this is the main way for the AI to react to player input. While this sometimes leads to indecisive behaviour the alternative is the AI being too slow to react when it comes to reinforcing battles which would also be bad. There may be some areas where the evaluation updates could be optimized though, for example the AI should already update province evaluation with the battle branch as soon as it knows that a battle will happen and not when the battle starts.
Concerning the number of provinces though I agree with you especially with a lot of military access involved the AI evaluates a lot of provinces which are not very relevant. It would be great to have some sort of strategic AI routine in the background which evaluates which regions are important for a given war and a given country and restrict province evaluation of armies to these regions.
- Lack of troops coordination. Which is very important in big wars. Typically as force limits increase in MP, it's good idea to focus on one area or create big army groups. It can be one or two combat Army's and rest is Reserves.
Good troop coordination is probably very difficult to implement and having infantry reinforcement stacks like in multiplayer would require a complete new AI logic for these stacks as they should not utilize the siege and battle branches the same way the main combat stacks do. This would likely require a big overhaul of the AI, otherwise this would obviously be great.
- 1 stacks are an issues, it's typically a splinter or reinforcements. I assume they have special evolutions, but they can be easily picked off. If Ai is overwhelmed in a mid / late game they just sit still.
Yes the splinters tend to freeze which is especially unfortunate now as merc companies are always considered splinters and therefore the AI is almost unable to use them properly. This is likely a whole series of nasty bugs in the AI code, which are impossible to pinpoint without seeing the code, some of which have been fixed back in 1.23 I think. But some remain and one can only hope for 1.31 as the higher prevalence (due to mercs) hopefully has placed this higher on the bugfixing priority list.
So the general idea is to make wars local if possible, and AI should operate from his home land prioritizing defence if it's necessary.
I had a quick a look at your mod and there are some modifiers which can be helpful in making AI evaluation more localized. As I am not sure how much you know about the relevant defines and there are probably other people who might find this interesting I will give a quick explanation on what works and how it works as far as I know:
(i) The ai_army files unfortunately do not seem to work (at least I was not able to do so trying multiple variants of codes the one from the examples, the one from the dd and multiple other plausible variants similar to other paradox code formats) and neither impact province evaluation nor AI troop movement. If you know otherwise I would be very happy to stand corrected.
(ii) The ARMY_DISTANCE_SCORE_IMPACT does work although in a non-intuitive way. Its inverse is multiplied with the Distance value seen in the AIeval mapmode but only for provinces which are interesting (i.e. where another branch besides the supply branch applies like siege or battle). Therefore the distance from armies has greater impact the lower the define is. While the change does not show up in the summands of the evaluation it does impact the end result. This might be helpful in reducing AI detours.
(iii)The BORDER_DISTANCE_SCORE_IMPACT does also work and in the same way as the army distance except that it is multiplied directly and therefore the larger the number the greater the impact.
There are other things like the MAX_TASKS_NEW_REGION_ASSIGN_ALGORITHM which can reduce the time it takes the AI to update regions but these are definitely the most important ones and when given the right values (ii) and (iii) can considerably change AI evaluation.

But generally I think that part with threat calculations is probably the strongest part of the system.
I do not think I can agree with this, well it depends on how bad you think the other systems are. To give some perspective related to multiplayer:
If at any given tech the AI thinks that 1 cannon is exactly as strong as 1 infantry when fighting directly it also thinks that a 40 Infantry + 40 Cannon stack is exactly as strong as an 80 infantry stack which is a pretty big misconception and if the AI is not able to calculate that attacking a reinforcement stack is better than attacking a battle stack I do not see much hope for its competitiveness in that regard.
 
  • 1Like
Reactions:

Orioniys

First Lieutenant
24 Badges
Apr 17, 2013
273
282
  • Crusader Kings II
  • Magicka
  • Europa Universalis IV: Call to arms event
  • Cities in Motion 2
  • Crusader Kings II: Sword of Islam
  • Crusader Kings II: Sunset Invasion
  • Crusader Kings II: Sons of Abraham
  • Crusader Kings II: The Republic
  • Crusader Kings II: Rajas of India
  • Crusader Kings II: The Old Gods
  • Crusader Kings II: Legacy of Rome
  • Crusader Kings III: Royal Edition
  • Crusader Kings III
  • Imperator: Rome
  • Surviving Mars: Digital Deluxe Edition
  • Age of Wonders: Shadow Magic
  • Age of Wonders III
  • Surviving Mars
  • Hearts of Iron IV: Cadet
  • Stellaris
  • Europa Universalis IV: Pre-order
  • War of the Roses
  • Victoria 2
  • Europa Universalis IV
(i) The ai_army files unfortunately do not seem to work (at least I was not able to do so trying multiple variants of codes the one from the examples, the one from the dd and multiple other plausible variants similar to other paradox code formats) and neither impact province evaluation nor AI troop movement. If you know otherwise I would be very happy to stand corrected.
To my knowledge it's not visible in province evaluation map mod, but I think it works. DD specifically states that trigger will not be checked on daily eval. I did some extreme tests month ago, I think it's rather weak and only works as a general direction. But it's hard to reliable confirm that.

It will be evaluated when any of the following happens:
- Whenever you gain or lose ownership or control of a province
- Whenever a war starts or ends
 

Ruian

Lt. General
30 Badges
Nov 17, 2018
1.682
368
  • Europa Universalis IV: El Dorado
  • Europa Universalis 4: Emperor
  • Europa Universalis IV: Golden Century
  • Europa Universalis IV: Dharma
  • Europa Universalis IV: Rule Britannia
  • Europa Universalis IV: Cradle of Civilization
  • Europa Universalis IV: Mandate of Heaven
  • Europa Universalis IV: Rights of Man
  • Crusader Kings II: Conclave
  • Europa Universalis IV: Cossacks
  • Crusader Kings II: Horse Lords
  • Europa Universalis IV: Common Sense
  • Crusader Kings II: Way of Life
  • Europa Universalis IV
  • Europa Universalis IV: Mare Nostrum
  • 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
  • Europa Universalis IV: Third Rome
  • Crusader Kings II: Sons of Abraham
  • Crusader Kings II: Sunset Invasion
  • Europa Universalis IV: Call to arms event
  • Crusader Kings II: Sword of Islam
  • Europa Universalis IV: Art of War
  • Europa Universalis IV: Conquest of Paradise
  • Europa Universalis IV: Wealth of Nations
  • Crusader Kings II
  • Europa Universalis IV: Res Publica
I definitely agree that the AI behaviour in AI vs AI wars is extremely important but I am not quite sure I understand what you are trying to say here. Would a more aggressive AI make pathways more or less linear and is this in your opinion desirable or not?
Less linear would be better. The Mamluks and Qara might actually win more than 1% of the time. Muscovy might not form Russia once in a while. There are dozens of examples of smaller countries that just disappear because the AI evaluation goes: you are stronger -> I shall wait for you to full siege me and send the peace deal.
 

Orioniys

First Lieutenant
24 Badges
Apr 17, 2013
273
282
  • Crusader Kings II
  • Magicka
  • Europa Universalis IV: Call to arms event
  • Cities in Motion 2
  • Crusader Kings II: Sword of Islam
  • Crusader Kings II: Sunset Invasion
  • Crusader Kings II: Sons of Abraham
  • Crusader Kings II: The Republic
  • Crusader Kings II: Rajas of India
  • Crusader Kings II: The Old Gods
  • Crusader Kings II: Legacy of Rome
  • Crusader Kings III: Royal Edition
  • Crusader Kings III
  • Imperator: Rome
  • Surviving Mars: Digital Deluxe Edition
  • Age of Wonders: Shadow Magic
  • Age of Wonders III
  • Surviving Mars
  • Hearts of Iron IV: Cadet
  • Stellaris
  • Europa Universalis IV: Pre-order
  • War of the Roses
  • Victoria 2
  • Europa Universalis IV
Less linear would be better. The Mamluks and Qara might actually win more than 1% of the time. Muscovy might not form Russia once in a while. There are dozens of examples of smaller countries that just disappear because the AI evaluation goes: you are stronger -> I shall wait for you to full siege me and send the peace deal.
Mam is probably the best example in that list. Half of his provinces is on a different continent, lots of big provinces and there is strait in gulf of aden. If Tunis gets involved on side of the Otto, it's just very hard for AI to manage this war correctly.

The rest are affected by institution penalties.
 

Ruian

Lt. General
30 Badges
Nov 17, 2018
1.682
368
  • Europa Universalis IV: El Dorado
  • Europa Universalis 4: Emperor
  • Europa Universalis IV: Golden Century
  • Europa Universalis IV: Dharma
  • Europa Universalis IV: Rule Britannia
  • Europa Universalis IV: Cradle of Civilization
  • Europa Universalis IV: Mandate of Heaven
  • Europa Universalis IV: Rights of Man
  • Crusader Kings II: Conclave
  • Europa Universalis IV: Cossacks
  • Crusader Kings II: Horse Lords
  • Europa Universalis IV: Common Sense
  • Crusader Kings II: Way of Life
  • Europa Universalis IV
  • Europa Universalis IV: Mare Nostrum
  • 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
  • Europa Universalis IV: Third Rome
  • Crusader Kings II: Sons of Abraham
  • Crusader Kings II: Sunset Invasion
  • Europa Universalis IV: Call to arms event
  • Crusader Kings II: Sword of Islam
  • Europa Universalis IV: Art of War
  • Europa Universalis IV: Conquest of Paradise
  • Europa Universalis IV: Wealth of Nations
  • Crusader Kings II
  • Europa Universalis IV: Res Publica
Mam is probably the best example in that list. Half of his provinces is on a different continent, lots of big provinces and there is strait in gulf of aden. If Tunis gets involved on side of the Otto, it's just very hard for AI to manage this war correctly.

The rest are affected by institution penalties.
99% win rate:
Brunei vs. Kutai
Majapahit vs. Sunda
Uesugi vs. everyone in Japan
Morocco vs. Tlemcen
Songhai and Mali vs. Western Africa
Kongo vs. Central Africa
Timurids vs. Vassals
France vs. England despite naval superiority

Sure, there are reasons some of these tags should have a higher win rate to keep history somewhat accurate. I've seen the Mamluks lose to the Ottomans after they declared the war and I had just taken a 100% peace deal and eliminated 90% of Ottoman troops. It's actually just so frustrating.
 
  • 1
Reactions: