almost 2 years ago - /u/ - Direct link
A lil somethin somethin: You can find the details for this event on the announcement page here.
almost 2 years ago - PDXRyagi - Direct link
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:








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:



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



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


(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:

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:

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.