• 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 19th of July 2022

Welcome to this week's Dev Diary! Today I'm back to talk about some of the changes we've made to the AI for 1.34.

National Ambitions

For a long time, there has been code and script for the AI to be aware of the conditions of its missions and decisions and try to achieve some of them. But because of various issues this has not had a significant impact.

For 1.34, we’ve made sure the AI takes many of these conditions into account, especially those related to conquests. We also made the AI pursue cultural unification, depending on government rank. These changes will work together with the AI’s more organic desires to shape its ambition and strategy. The result is an effect which is just noticeable in terms of AI behavior, but compounds over time to create AI empires - sometimes historically reminiscent - that provide a real challenge to players who continue into the late game.

We were a little worried that this might cause games to all look the same, but our hands-off overnight games look arguably even more varied than before.

Here are a bunch of recent hands-off 1821 maps, only slightly cherry-picked:
num1.png num2.png num3.png num4.png num5.png num6.png
It makes us happy and proud to see the AI form historical countries such as Germany, Italy and Qing.

Typically, these AIs balance off each other nicely. If your plan as a player is to “Kill Ottomans early, then chill”, you may find that you’ve just aided some other AI in taking their place as your end-game boss. Admittedly though, a downside of this more opportunistic AI is less clean borders.



Peace Negotiation

What started out as an investigation into why AIs often left OPMs alive in peace deals, turned into a slightly bigger project.

When the AI is winning a war, and making demands, it has a bunch of preferences that it tries to balance against each other for an optimal peace deal. This is unlike when it is losing, where it will only care about objective measures such as war score cost. However, when the AI is winning, but receives an offer, it has previously relied on very coarse-grained expressions for whether the offer matches its preferences:
  • “Does not want parts of the offer”
  • “Requires X to be part of the offer”
  • “Wants other concessions than gold”
This has given clever players a little too much room to outsmart the AI.

In 1.34, the second expression in particular has been reworked, to allow the AI to express its preferences in more detail. Let’s take a look at an example:

no_candar.png


Here, I was trying to get out of a bad situation by giving away my ally’s land, but Nassau wouldn’t have it. It’s not that they don’t want Candar to be released - note the green thumb - it’s that they’d much rather have me release some of my own land. Unlike the old “Requires X to be part of the offer”, this new condition can not be circumvented by completely filling the peace deal with less important treaties.

As a consequence of this, we’ve also been able to loosen up the “Does not want” condition by making the thumbs green in more cases.

One more subtle but important change is that when an AI warleader considers a separate peace with individual enemies, it will be more lenient. This helps expanding AIs take more stuff, while also reducing the risk and cost of war, compared to just waiting for the enemy warleader to sign a deal. It will also make it more risky for players to start a war where they rely too heavily on their allies.

As a related side note, we’ve fixed a crash related to the PRESS_THEM_FURTHER moddable define. If enabled, it makes your war allies who have been promised land get mad at not getting enough land, even if the war leader doesn’t take anything for itself.



Independence Wars

independence.png


Given that we’re doing a Scandinavia-themed update, it seemed appropriate to do something about subjects’ willingness to declare independence. We haven’t changed a lot, but subjects will overall be a bit bolder when it comes to declaring independence. In particular they may now do it while at war, if at 100% Liberty Desire, so no more constant wars to pacify your subjects. There’s not much more to say about it, but we can for example see independent Sweden a bit more often, as well as a collapsing Timurids and occasionally breakaway nations in the Americas.



War Evaluation

tunis_reasons_before.png

(But Tunis will accept once I start the war)

When the AI considers starting a new war, it will look at basically the same information as the player can see in this window to figure out who will join on either side. Unfortunately, this has had a couple of bugs, related to the “Attitude towards enemies” and “Distant war” reasons potentially changing as the war starts and additional countries join. This has made both players and AIs declare suicidal wars.

These inconsistencies have now been fixed, where we could find them. But the problem remains when predicting acceptance for recursively called allies (such as allies of the Holy Roman Emperor when attacking a member state). Because of this, already in 1.33, the player interface doesn’t try to tell you whether those countries will join or not. But the AI still tried to “look at the checkmark”. In 1.34, the AI will simply assume that recursively called countries would all join. This will fix the “Burgundy suicides into Liege” bug.



Passive Subjects

Players with Rights of Man are able to set their subjects’ military focus to “Passive” and “Defensive”, but these focuses have been a bit wonky for some time. We fixed a number of bugs with these for 1.34, and there is one I would especially like to share.

In very simplified terms, this is how Passive was originally coded:

Code:
Objective #1: Avoid foreign territory.
Objective #2: Avoid enemy armies on home territory.
Objective #3: Avoid attrition (with a big margin if possible).

But then single-province subjects with big armies would stay and take attrition (especially if another country is also standing there), as well as when enemy armies are approaching. So the objectives were reordered:

Code:
Objective #1: Avoid enemy armies on home territory.
Objective #2: Avoid attrition (with a big margin if possible).
Objective #3: Avoid foreign territory.

And it turns out the AI knows you can’t take attrition while fighting a battle… So “passive” subjects would sometimes actively seek out enemy armies on foreign territory in order to avoid attrition!



Other

There have been a number of improvements to for example army and navy handling. This Dev Diary is already long enough, but the biggest bug worth mentioning is when the AI would just lock its armies in place near the coast, while its navy was too afraid (often irrationally) to come and pick them up. This easily caused e.g. Denmark/England/Spain not making themselves useful in wars.

Historically, many AI bugs have been caused late in the development cycle of a patch, perhaps because they often need time to be found. Right now, we’re quite happy with the state of the AI in our internal builds so we will try not to repeat that mistake by stirring things up before 1.34 releases.



Patch Notes

Here are roughly the AI-related patch notes so far. This is still WIP and a more final and curated list will be released in connection with the update as usual.

Buildings
- AI will now properly calculate when to construct Docks based on a multitude of factors such as sailor percentage, idea group choices, capital position and more.
- Fixed that AI sometimes deleted all forts right after a bad war.
- Fixed another case of AI deleting forts unnecessarily.
- Fixed bug that 'Conqueror' ruler personality made AI delete all/most forts.
- AI less keen to build fort in capital (though still preferred). This will somewhat reduce the fort slog in Central Europe.

Budgeting
- Changed AI budgeting algorithm to be more flexible. Fixes e.g. small CNs sometimes not colonizing when they should.

Geopolitics - Declare wars
- Fixed some cases of AI declaring war over provinces it can't/won't take.
- Made AI less likely to declare war on island nations it lacks the transports to invade.
- Fixed bug that revolutionary AI could declare war on coalition target with any cb, thinking coalition members would join.
- AI is no longer blocked from declaring independence when at war.
- Fixed bug that sometimes made aggressor AI erroneously think HRE allies would refuse to join when attacking HRE minors.

Geopolitics - Missions and Decisions
- Added AI weights to mission trees which make them now more considerate which mission they want to strive for and how much (for context related reasons).
- AI now understands and tries to achieve army_size and army_size_percent triggers in missions.

Geopolitics - Other
- Fixed bug that AI couldn't get hostile towards, and hence rarely attacked, others’ vassals and some other subjects.
- AI is now better at evaluating when to annex/integrate a subject.
- Fixed bug that catholic AI colonial nations avoided expanding into overlord's Tordesilla regions.
- Reduced AI avoidance of having interest in provinces that are vital to allies.
- AI Duchies are now permanently interested in provinces of their culture, Kingdoms their entire culture group, and Empires also all provinces on their border.

Peacemaking
- Fixed some issues with AI peace acceptance 'wants other concessions than gold' and 'does not want anything else', causing AI to often leave OPMs in peaces.
- Fixed bug sometimes preventing AI from taking the last enemy province.
- AI warleaders are now more happy to make separate peaces with non-cobelligerents.
- AI will unconditionally surrender in more cases.

Army
- Fixed one bug that made AI send armies far away instead of defending home.
- Made AI more likely to reinforce adjacent battles.
- Improved AI attrition handling. Should get both less attrition and less confused behavior.
- Fixed bug that AI helped allies with rebels even when at peace.
- AI overlord now treat subjects' rebels like their own in more cases.
- Fixed bug that made AI ignore flanking when evaluating battle.
- Fixed multiple cases of AI subjects being stupid when set to Passive or Defensive.
- Increased preferred size of AI armies, especially late game.
- Increased AI desire to disrupt sieges, especially with high progress.
- Improved AI logic for when to abandon sieges.
- Made AI armies prioritize coordinated offensives more.
- Made army AI try to stay close to enemy armies when it has nothing else to do.
- AI somewhat more likely to defend homeland.
- Improved AI for consolidation before battle.
- Fixed instance of AI armies going back and forth when sieging.
- AI vassals no longer delete exiled armies if they can get home.
- Fixed issues with autonomous sieging and rebel suppression missions.
- Fixed case of AI armies canceling movement every other day

Navy
- Fixed some issues with AI naval invasions.
- Made AI better at understanding when a naval invasion risks being intercepted.
- Fixed bug that made AI often unassign general when naval invading.
- Fixed yet another case of AI naval invasion stalling forever.
- Made AI fleets consider troops further away when protecting straits.

Trade Company
- Fixed bug that AI sometimes wouldn't ever core Trade Company provinces.
- AI will no longer accidentally remove trade companies by creating states.

Cheats
- Fixed bug that AI could add provinces to HRE when emperor, even if not a member.
- Fixed bug that AI could use Break Alliance for Favors diplomatic action with Leviathan disabled.

That's it for today. I hope you found this Dev Diary interesting!

Next week my colleague @Pavía will be showing all the new Monuments that will be added in the 1.34 Update, along with some game balance and changes we want to share and discuss with the community, coming also for free in the update.
 
  • 132Like
  • 68Love
  • 11
  • 3
  • 2
Reactions:
- AI will unconditionally surrender in more cases.
Could you elaborate on when the AI surrenders unconditionally? Will this make it more difficult to get 100% warscore without a surrender so that the player can offer a deal to the AI in which the player loses something which the AI doesn't want(e.g. a province or letting the AI force religion on the player)?
 
  • 3
Reactions:
- AI Duchies are now permanently interested in provinces of their culture, Kingdoms their entire culture group, and Empires also all provinces on their border.
Will this affect relations with allies? Will they receive the "desire province" relationship malus if you border them and they're an empire?
 
  • 9
  • 3
Reactions:
I'm somewhat worried that the new culture centric expansion ambitions will turn the HRE into a thunderdome. In all but one test game, the HRE gets taken over by a single nation... which is fine if it happens towards the end of the timeline, but if the HRE majors start consolidating too early, that will take some of the fun out of a HRE game.
 
  • 17
  • 1Like
Reactions:
I don't see any of the native turbo-federations in the hands-off game maps, which is a good sign. I wonder if there are more changes to those systems that will be in the final patch notes, or if the AI updates have just caused the Europeans to be better at handling the Americas...
 
  • 8
  • 4Like
  • 1
Reactions:
Very nice. The one thing that I would expect to find under AI is the blatant aggression of natives, did you address that? Or is fixing the bug that gives colonized tribal land and unowned cores to a newly formed federation tag enough? It looks like colonizers are succesful again in the overnights, which is good :)
 
  • 3Like
  • 1
Reactions:
Is the Peace of Westphalia counted into these AI changes? I can imagine the Religious wars becoming invariably complex as it mashes 20+ states on either sides interests.

Better AI is always welcome though.
 
  • 3
Reactions:
Were there any changes to Colonial AI management? Will keep seeing Native AI immeditly murdering our colonies the second they come into existence? Also is the colonial AI now more likely to culture shift provinces to the correct culture if it isn't, as this one of largest problems for colonizers in Mexico and Peru.
 
  • 5Like
Reactions:
If you want players to take the AI seriously. Just teach them how to build a country instead of spamming naval batteries and churches teach them to build factories, force limit and manpower.
I don't think it's difficult to configure the AI to prioritize useful buildings, instead of useless ones. Several of the "bad" buildings are unlocked early causing the AI to have no places to build the good ones. Also, the good ones are more expensive so the AI gets 100 ducats and spends it on a coastal battery instead of waiting for 500 to build a factory.
I think this aspect of AI is very important and has been largely ignored. Even if the AI were to go besiege a fort on the other side of the world, if they build a stronger country with more troops, manpower and money they can better compensate for the mistake.
 
Last edited:
  • 4Like
  • 3
Reactions:
Every change which would cause me spending less time chasing enemy armies into Siberia while I'm carpetsieging their homeland in Italy is a welcome one. Cheers for your work on these !
 
  • 9
Reactions:
The Burgundy vs Liege fix is tempting me to recant my position on simply waiting for EU5. I am such a sucker for inheriting Burgundy and it sounds like they'll do much better now.
It always felt like burgundy was a sandwich that someone took a bite out when it committed the Liege war. France always afterwards declares war and takes part of its territory. Now you might be able to get a nice looking inheritance :oops:
 
- Fixed bug that AI couldn't get hostile towards, and hence rarely attacked, others’ vassals and some other subjects.

Does this mean that AI Ottomans will want to attack Hungary while they are a PU under Austria, Muscovy will push for their claims on eastern europe even if Lithuania is under PU with Poland and so on? Because if so, thats a big change actually
 
  • 8Like
  • 1
Reactions:
In 1.34, the second expression in particular has been reworked, to allow the AI to express its preferences in more detail. Let’s take a look at an example:

View attachment 861892

Here, I was trying to get out of a bad situation by giving away my ally’s land, but Nassau wouldn’t have it. It’s not that they don’t want Candar to be released - note the green thumb - it’s that they’d much rather have me release some of my own land. Unlike the old “Requires X to be part of the offer”, this new condition can not be circumvented by completely filling the peace deal with less important treaties.

As a consequence of this, we’ve also been able to loosen up the “Does not want” condition by making the thumbs green in more cases.

One more subtle but important change is that when an AI warleader considers a separate peace with individual enemies, it will be more lenient. This helps expanding AIs take more stuff, while also reducing the risk and cost of war, compared to just waiting for the enemy warleader to sign a deal. It will also make it more risky for players to start a war where they rely too heavily on their allies.

As a related side note, we’ve fixed a crash related to the PRESS_THEM_FURTHER moddable define. If enabled, it makes your war allies who have been promised land get mad at not getting enough land, even if the war leader doesn’t take anything for itself.

Not bad, but I wish you guys came up with a yellow hand for cases like that - leaving the green thumb only for the options the AI will outright accept.
 
  • 4
  • 2
Reactions:
  • 22
  • 2Like
  • 1Haha
Reactions: