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

Europa Universalis IV - Development Diary 25th of January 2022

Hello folks, Gnivom here.

Today I’ll talk about some of the many AI updates coming in the next patch, 1.33. At the end I’ll also mention some minor but impactful changes to the rules of land combat.

Our last major update, we shipped some AI improvements, but a few new issues slipped through as well. Two of those in particular (advisors and forts) were too complex to make it into any of the hotfixes. For 1.33, we have not only addressed those issues, but done a range of further AI fixes/improvements as well. Because of the large number of changes, some new AI issues will probably slip through this time as well. Our goal is to have a public beta for 1.33, which could help a lot with early feedback and time to address it before the final release.

Forts

The issue introduced (or at least worsened) in 1.32 was that the AI deletes many of its forts, and seldom builds new. This was likely triggered by changes we did to tighten the AI’s budget, as it had had serious budget issues for a number of versions before that. Clearly we couldn't just revert the changes blindly. Instead I wanted to dig deeper and fix underlying issues with the AI's handling of forts.

For example, there has for a long time been a bug that caused large countries to only build level 2 forts. In simplified terms: When the AI "defense minister" considered upgrading a fort, it wanted to make sure it could afford upgrading all its forts to the same level, or it would only upgrade to a lower level. So it asked the AI "finance minister" if it can afford maintaining e.g. 10 level 4 forts, but the finance minister says no, reasoning that "you shouldn't need this much money for building one fort". So the AI was in a stalemate, where it could only build the lowest level of forts.

Another issue was fort mothballing. The AI would often mothball forts in a way that allowed players to blitz them.

The result after spending some time with this is an AI that seldom deletes any forts, often upgrades forts to higher levels, sometimes builds new forts (especially in strategic locations with good terrain), and is much more careful/intelligent with mothballing. Of course, the AI will still delete forts it really can't afford (such as QQ at game start), and it doesn't have human-level tactical or strategic understanding of fort positioning. But overall, I hope you will find it a big improvement :).

ai_forts.png

(All of these are level 8 forts, in an 1821 AI-only game. Maybe it’s a bit front-heavy…)

Advisors

In 1.32 the AI rarely hires advisors, and often fires them as soon as they're at war. This too was the result of code intended to tighten the budget. Like with forts though, it turned out that there were other issues worsening the problem.

One such bug was that when deciding which mana it needed the most, two of them could tie for first place - causing the AI to pick the third (worst) type instead. This made the AI hire diplo advisors way too often. Another obscure bug was that if it took the AI too long to save up the money for the initial advisor cost, it could lose track of it, making the money "earmarked" but ever used.

In 1.33, the AI will usually keep a reasonable amount of advisors, often prioritizing military or admin. A reworked threshold system makes it not hire-and-fire advisors frivolously. AIs with Meritocracy will realize the importance of having enough advisors to keep it growing. With these improvements, and considering how it stacks with some Monuments and Estate Privileges, we've decided to remove the -20% Advisor Cost modifier for Lucky Nations. Most of them are doing more than fine.

Other budgeting

Other areas where the AI sometimes didn't spend enough include colonists and missionaries. Colonial Nations and AIs with Colonialist personality in particular will spend a larger amount on colonization. One neat addition is that Colonial Nation subjects will now direct all received subsidies towards colonization, in addition to what they would otherwise have spent, unless they have loans. This lets their overlord (or anyone else ;)) make sure they put their colonists to work.

Peace-time armies are now also a greater priority for small nations, especially for those without powerful allies/guarantors. You should find for example uniting Ireland to be more challenging.

Now of course you may wonder, if all these things get more spending, won't the AI go into debt spirals again? It turns out there were a couple of places where spending could be cut:
- Drilling armies: The AI now only does this only if it has a large budget surplus
- Corruption: Sometimes it makes sense to get "free money" for corruption, but the AI overused that, and then found itself rooting it out at several times the cost.
- Navy Force Limit: It makes sense for some AIs to go above Naval FL, but this has been reduced somewhat.
- Consolidate Regiments: When the AI finds itself with troops it doesn't need at the moment, usually after a war or a battle with rebels, it will consolidate regiments.
- Fort maintenance: Wait, didn't I say the AI is better at maintaining, building and upgrading forts? Sure. But in some cases, in particular poor OPMs with an expensive capital fort, mothballing it really can be worth it.
- Inflation: By giving a higher prio to reducing inflation, many AIs reduce all expenses by several percent.

If these measures are not enough, when the AI goes into longterm deficits and debt, it will implement progressive austerity measures. Firing advisors, reducing army size, and even deleting forts. As far as I've observed, this only happens during/after severe crises, and works fairly well.

The budget is also significantly helped by increased crownland, which we'll get to later.

eth_economy.png

(16’th century Ethiopian budget, recouping after an expensive war. They’ll soon lower army maintenance and mothball a couple of forts to get a better surplus)

Monarch Power (mana)

At release of 1.32, there was a major issue with AI mana spending, causing the AI to often fall behind in tech and/or ideas. This was made worse by how it interacted with the new institution tech cost, and by the issues with advisors mentioned above. Although a hotfix was issued including a fix to the main issue, we've spent more time looking at the AI's mana economy. The AI now:
- better understands when to buy tech vs. ideas vs. other things.
- uses more advisors (as mentioned before).
- uses Estate Privileges for free mana.
- better understands when to prioritize a certain mana, in terms of National Focus, Advisors, and Estate Privileges.

It also turns out that if you play a Republic, and especially with Plutocratic ideas, choosing randomly between the event options of those events can cause you to spend a majority of your ADM on boosting stability. We've gone through many of the events affecting Stability and/or Republican Tradition, and made the AI pick the better/safer option.
Estates

When the Estates system was last redesigned, AI was written to interact with it. But that AI wasn't necessarily written/tested too carefully, and years of design changes and lack of proper attention have made it worse.
It turns out that by making the AI play a fairly simple estates meta, but play it consistently, it gets quite a nice set of bonuses; from tax income and autonomy reduction, to mana; at very small cost.
The AI will:
- Seize Land even when it causes revolts (but only after maintaining troops and forts)
- Occasionally Call Diet to temporarily increase Loyalty, although it doesn't usually try to complete it
- Prioritize Privileges that give loyalty and mana
- Sell Titles only when crownland is high and/or the money is badly needed

Naval Invasions

1.32 saw some fixes in this area. 1.33 will have a couple of further small improvements/fixes that should reduce friction for multi-continent empires in particular. For example:
- Armies that have nothing to do are less likely to refuse an invasion mission
- Invasions will no longer wait for faraway ships to help out, unless they are necessary

In one game, I actually saw AI Portugal conquering a third of India by 1700 or so, while also having colonies in the Americas and Africa. But in fairness, that is not a common sight. AI naval invasions will remain an Achilles’ heel.

Army Quality

This is a major one. And huge thanks to @Tempscire, who has helped me with running simulations, with mathematical analysis, and schooling me on how EU4 land combat actually works.

The question the AI is trying to answer here is whether to start a battle, or even a war. To do so, it must estimate the quality of troops. Basically: how many Swedish soldiers does it take to equal 1 Prussian soldier? Until 1.32, the AI did this by applying a series of modifiers, based on Discipline, Morale, etc., that were tuned on gut feeling. From 1.33 (and somewhat already from 1.32) we have proper math and simulations to back them up.

The AI now appreciates the value of morale more than before. It understands how a general’s impact on a battle depends on the terrain. It understands the interplay between e.g. Infantry Fire, Fire Pips of the Unit Type, Fire Damage, and Infantry Combat Ability. It also understands combat width and flanking, but it doesn’t yet understand army composition between infantry/cavalry/artillery. That is definitely something to continue working on.

With this improved confidence in its understanding of army strength, the AI’s safety margin for starting attacks has been reduced somewhat. It has also been made more aware of nearby armies on both sides. You will find the AI starting more winning battles, and hopefully fewer losing battles. Although the reduced safety margin combined with bad understanding of army composition can make the AI fail in this regard.

Changes to Land Combat

The thought that went into the army quality AI made us realize (again, with @tempscire’s guidance) we should change some things about how combat works. As mentioned in last week’s DD; Unit Type Fire and Shock pips now affect morale damage as well strength damage. This makes the choice between Unit Types less imbalanced. Contrary to what was said last week, and in part because of feedback on that post, this will also apply to morale defense from backrow. The fact that this makes artillery more powerful and battles longer is counteracted by some more important changes we decided to do:
  • Infantry and Cavalry can no longer deploy/reinforce to the backrow.
  • Backrow regiments will now retreat when reaching 0% morale (same as frontrow regiments).
  • Constant 0.03 morale damage per day is now only applied to reserves, and not to regiments on the battlefield.

I’m sure many of you (just as myself not too long ago) do not understand how this affects the combat meta in practice. Without making this DD much longer than it already is, some important effects are:
  • It’s no longer critically important to have a full combat width of artillery in the battle on day 1.
  • An army of 2x combat width infantry is now superior to an army of 1x combat width infantry. Previously they were roughly equal.
  • You’ll need more artillery than just the combat width to last a long battle.


That’s it for this week, hope you’re as excited for 1.33 as I am!
Next week @Pavía will make a Dev Diary on the subject of “Script Debt”.

Thanks again to @Tempscire, but also to @xorme whose AI mod inspired some of the improvements. And thanks to everyone who provides great feedback on this forum and elsewhere!

Oh, and here is a full list of AI-related changes from the in-progress changelog:

- Fixed Celestial Emperor advisor budgeting issue.
- Rewrote AI savings logic.
- Colonial nations spend more money on colonists.
- Increased AI minimum colonization budget.
- Reworked AI fort mothballing forts.
- Fixed issue that AIs in debt didn't convert provinces.
- Made AI consider flanking.
- AI better understands importance of generals' pips.
- AI now considers units' drill before starting a battle.
- Fixed bug where AI thought 'coordinated attack' and instead sent individual armies to die.
- Fixed multiple issues with scripted ai_army, one of which made it not work at all. It can now also be debugged with the 'mapmode armyeval' command.
- The AI now makes smarter decisions regarding Patriarchal Authority in events.
- AI better at consolidating regiments before battle.
- AI can now declare wars when overextension is up to 50% (previously 25%), but only if already coring everything.
- AI considers nearby units more when considering a battle.
- AI will now seize land from estates more often, but raise army/fort maintenance.
- Added AI priority to a few conquest missions of France and the Ottomans in order to ensure them prioritizing their missions.
- Better at taking home troops overseas (instead of disbanding).
- Build a bit more universities.
- Made AI Care about beijing, nanjing, canton for mandate.
- Made AI Care about corruption for mandate.
- Celestial Emperor more aggressive towards countries that refuse to pay tribute.
- Colonial Nations without debt are now likely to spend all subsidies they get on colonists.
- Colonial subjects will care more about wars against countries in their colonial region.
- Coordinated offensives will now focus on committed sieges.
- Fixed AI army ignoring terrain for some threat evaluation.
- Fixed bug that AI sometimes ignored armies with insufficient troops for siege.
- Fixed bug that caused exiled armies to behave erratically.
- Fixed bug that made AI less afraid of non-rebel armies, when it should be rebel armies.
- Fixed bug that made AI not declare easy wars as often.
- Fixed bug that made colonial nations not colonize islands in their own colonial region.
- Fixed issue where armies would refuse to do things nearby, because it was assigned to a region far away.
- Fixed issue with colonists not being recalled when they should be.
- Fixed issues sometimes preventing AI upgrading forts to higher level.
- Fixed issues with colonial budgeting (causing bankruptcy spirals).
- Fixed that autonomous sieging could go back and forth between provinces that were flipped back by a fort.
- Improved AI understanding of native uprising risks (less africans getting stackwiped taking a shortcut).
- Improved AI handling of estate privileges.
- Improved army quality calculations.
- Improved handling of corruption.
- Improved handling of inflation.
- Improved logic for where to build forts.
- Improved national focus (mana) handling.
- Improved the AI decision making for Orthodox events.
- Increased budget priority for saving money.
- Made AI less eager to demand return core treaty unless it likes the benefactor.
- Made AI less eager to go over naval forcelimit.
- Made AI less likely to mothball forts when risky.
- Lowered AI priority on building great projects over other buildings.
- Lowered AI safety margin when attacking to compensate for other fixes.
- Made AI aware of risk of rebels spawning in a province.
- Made AI chase your small armies in more cases.
- Made all chinese countries want to conquer the 3 Mandate cities, if they have 1 already.
- Made AI armies which are afraid of enemies, prefer safe terrain even more.
- Made AI more likely to enforce rebel demands (peace treaty) in the rare case that it can do so.
- Made AI more likely to promote cultures (with large development).
- Reduced maximum budget for subsidies to 10% of income.
- Several fixes and improvements regarding advisors.
- Somewhat more competent at naval invasions for large empires.
- Subjects with loans will keep a standing army again (although it will be small).
- The Ethopian AI will no longer move its capital while being at war.
- Tweaked AI siege priorities.
- Very small countries with scary neighbors will now keep a larger army when at peace.
- Made AI less likely to split armies in threatening places.
- Made AI more happy to hunt nearby armies.
- Army AI only takes its own armies on fleets.
- Fixed small AIs militarizing also when Rights of Man DLC disabled.
- Improved Strong Duchies AI.
- AI can handle reassigning merchants.
- AI no longer sells provinces to charter cheaply, and added new malus for presence of great projects in the province too.
- AI no longer uses pillage capital state when it has nothing to gain from it.
 
Last edited:
  • 126Like
  • 59Love
  • 13
  • 5
  • 2
  • 1Haha
Reactions:
With so many great changes coming in 1.33, would it be possible to open up the game a bit more for the modders? There is a lot of stuff that is either hardcoded or can be only changed globally, such as some religious mechanics which can't be replicated with new effects for a new religion, special units, just to name a few.

Would it be possible to change it in the future?
 
  • 20Like
  • 3Love
  • 3
Reactions:
Ain't sure if such fort line isn't overkill tho but it can be balanced in the end. Overall, looks really decent, I hope most of the potential issues will be resolved in beta. gl
 
  • 10Like
Reactions:
Pls nerf force limit and manpower gain through colonial nations plus their own force limit (would also help the game if mexico did not have over 200k in late game).
 
  • 22Like
  • 7
  • 2
Reactions:
Lots of Great AI improvements... can't wait until to try it out and observe the AI!

I have a question though.

In the patch notes you mention chinese AI focusing to conquer nanjing, beijing etc.
As far as I know, the implementation of those penalties is based around triggered modifiers that penalize the mandate holder if they don't control those provinces. Does that mean the AI takes the triggered modifiers into account or perhaps it is a a hardcoded feature (would be unfortunate for mods that change the target provinces)?
 
  • 5
  • 1
Reactions:
I really like these changes for AI. Especially to their fort management. Glad that the 1.33 will be focused on balancing and fixes.
Also, there is one thing that I found in my Teutons run, that contradicts history. In the game “The Prussian Confederation Revolts” event can only fire after the year 1460, while in reality Prussian Confederation allied with Polish King and rebelled in 1454. I think this should be fixed.
Here is the source: https://en.wikipedia.org/wiki/Prussian_Confederation
 
  • 2Like
Reactions:
Lots of Great AI improvements... can't wait until to try it out and observe the AI!

I have a question though.

In the patch notes you mention chinese AI focusing to conquer nanjing, beijing etc.
As far as I know, the implementation of those penalties is based around triggered modifiers that penalize the mandate holder if they don't control those provinces. Does that mean the AI takes the triggered modifiers into account or perhaps it is a a hardcoded feature (would be unfortunate for mods that change the target provinces)?
Great question!
I added ai_weight to all triggered_modifiers. In script it looks like this:
ai_wants_chinese_capitals = {
potential = {
ai = yes
OR = {
owns = 1816
owns = 1821
owns = 667
}
has_dlc = "Mandate of Heaven"
capital_scope = {
superregion = china_superregion
}
}
trigger = {
owns = 1816
owns = 1821
owns = 667
}

ai_weight = {
factor = 100 # Makes AI try to conquer the cities
}
}

lost_control_of_beijing = {
potential = {
has_reform = celestial_empire
has_dlc = "Mandate of Heaven"
}

trigger = {
OR = {
NOT = { owns = 1816 }
NOT = { controls = 1816 }
}
}

ai_weight = {
factor = -1000 # Do what you can to avoid this modifier
}

imperial_mandate = -0.05
}
 
  • 15Like
  • 8Love
  • 3
  • 2
Reactions:
Other areas where the AI sometimes didn't spend enough include colonists and missionaries. Colonial Nations and AIs with Colonialist personality in particular will spend a larger amount on colonization. One neat addition is that Colonial Nation subjects will now direct all received subsidies towards colonization, in addition to what they would otherwise have spent, unless they have loans. This lets their overlord (or anyone else ;)) make sure they put their colonists to work.
Does this mean colonization is going to be even faster now than it used to be?

Any chance to reduce settler growth increase from tech, or slow down colonization in some way?

Also, settler growth should be somewhat connected to the total development of your primary culture, since you colonize with people from the primary culture, and clearly a nation of 100k would never be able to colonize as fast as one of 10M.
 
  • 14Like
  • 2
Reactions:
Has the AI learned to embark/disembark troops from transports when going to/from its own provinces yet instead of doing a laborious naval landing to them?
 
  • 2Like
  • 1
Reactions:
Can you elaborate? I assume you mean that artillery will retreat due to reaching 0 morale?
Exactly. Because artillery can now retreat, you will want to have reserve artillery as well, if you're fighting a long battle.
 
  • 24
  • 6Like
Reactions:
Has the AI learned to embark/disembark troops from transports when going to/from its own provinces yet instead of doing a laborious naval landing to them?
Yes. I believe that was done for 1.32. But anyway, now they do that most of the time (though sometimes they do an amphibious landing to an enemy province when they could just disembark the province next to it)
 
  • 10Like
  • 8
Reactions:
Damn, those are some great changes! Really love to see the AI being given some love, as they were pretty shocking in earlier version (*cough* Emperor *cough*).

Any changes to how the AI prioritises the player in Alliance wars? Eg will they now hold their country or transport troops over to the player's land?
 
  • 1Like
Reactions:
Hyped about these changes! Also please add an image to this dev log, any really, because otherwise it might fly under the radar for people randomly scrolling throughout the website.
Thank you! It's my first time posing a DD, and I'm having technical issues :p. We should get a feature for it too...
 
  • 9Like
  • 5
  • 1Love
Reactions: