Diplomacy AI Development

Not sure if this was reported already but we used to be able to gift cities back to vassals (usually their own cities back after conquering and making them capitulate. When you try to do it now, it says "impossible" and they won't take the gift.
 
Strange thing about the antiquity site opinion. I haven't finished digging the artifact (was planning to build a landmark for them) but they already have the -20 opinion. And it turns out since Open Borders ends in 2 turns I can't finish digging it anyway.

Is this going to stick forever?

Spoiler Screenshot :
cRcuiMu.png


EDIT: Also, Ethiopia, vassal of Persia just gave me the option of declaring war through the "your 2 ships are parking too close to my territory" menu. What happens if I click DECLARE WAR?
 
Last edited:
I've seen a trend lately of civs offering early declarations of friendships, often my immediate neighbours. Then ten to twenty turns later (on Epic) they suddenly realise that I'm their best target and denounce and sometimes then attack me. Just had this happen with Mongolia attacking me as Babylon. Maybe the AI should be a bit more logical with who it offers a declaration of friendship since Authority Mongolia didn't really have anybody else to attack but me, so it doesn't have to eat a backstabber penalty. Or just rate breaking a diplo penalty higher.

No complaints with the tactical Mongolia AI. They just ripped right through my armies, with their extra movement and no Zone of Control Chariots. My armies were out of position, knocking down Morrocco for forward settling me since I foolishly trusted the friendship to give me some time. The only issue is the AI doesn't seem to want to leave any movement points left, so the chariots sometimes maneuvered ontop of rough terrain where they were vulnerable, instead of just staying on the safe flat plains.

Do they end their DoF by denouncing? AI is currently programmed never to DoW their friends.

As for friend choices, I'm working on it, but I've paused my changes (aside from bugfixes) for the time being to allow G to release a more stable version.

Tactical AI issues should be reported on Github.

Not sure if this was reported already but we used to be able to gift cities back to vassals (usually their own cities back after conquering and making them capitulate. When you try to do it now, it says "impossible" and they won't take the gift.

I'm aware, not sure how to fix it though. I'll take another look at all these bugs today.
 
Last edited:
Strange thing about the antiquity site opinion. I haven't finished digging the artifact (was planning to build a landmark for them) but they already have the -20 opinion. And it turns out since Open Borders ends in 2 turns I can't finish digging it anyway.

Is this going to stick forever?

Spoiler Screenshot :
cRcuiMu.png


EDIT: Also, Ethiopia, vassal of Persia just gave me the option of declaring war through the "your 2 ships are parking too close to my territory" menu. What happens if I click DECLARE WAR?

Found the problem for the artifact penalty, fixed for next version. There was old code in CvUnit.cpp that I didn't know about. :) In your current game, it shouldn't be applying a permanent penalty, just a temporary opinion penalty.

You declare war, as usual. It isn't a bug for vassal players to send this statement to humans, but it is if they send it to AIs since it could cause a DoW on a vassal (which has also been fixed for next version).
 
Last edited:
Do they end their DoF by denouncing? AI is currently programmed never to DoW their friends.
Do you mean like never ever ever? Is it desirable? If I manage to get a DOF with an aggressive neighbor, then I can send my army elsewhere and be sure that I have nothing to worry about? I'd rather there is still a tiny chance that they'd backstab me ...
 
Persia just let their capitulated vassal Ethiopia go peacefully. I think the former initiated it too. First time I've seen that with AIs.
 
Do you mean like never ever ever? Is it desirable? If I manage to get a DOF with an aggressive neighbor, then I can send my army elsewhere and be sure that I have nothing to worry about? I'd rather there is still a tiny chance that they'd backstab me ...

Currently, that's how it's supposed to work, yes. I will change it to allow a small chance of backstabbing later, but getting the AI to do this intelligently is difficult, and I had some problems with the diplo AI memory system while trying to implement backstabbing penalty reforms. The memory system has confused and hindered me for a while, so I'm currently chipping away at fixing it (which is a slow process, but that's fitting considering I'm waiting for the next stable release :)).

Persia just let their capitulated vassal Ethiopia go peacefully. I think the former initiated it too. First time I've seen that with AIs.

It does happen, albeit rarely.
 
UI work isn't my specialty, but I've had an idea I plan on implementing in the future.

I'd like to add a button to the Discuss menu: "What can we do for you?"

This would allow the human to ask the AI what they can do to improve relations, without being obtrusive since, e.g. AI popping up every few turns to tell you what you could do for them would probably get annoying for some players.

Don't expect to see this soon, but when I rework diplo interaction logic it's on my to-do list.
 
So, Persia came to me just to say that my army was a laughing stock of the world. I was #2 in army score in demographics, and #1 by a huge margin in the popup rankings (since I only have 5 cities, presumably). 3-1b version, but I assume that logic hasn't been changed.
 
So, Persia came to me just to say that my army was a laughing stock of the world. I was #2 in army score in demographics, and #1 by a huge margin in the popup rankings (since I only have 5 cities, presumably). 3-1b version, but I assume that logic hasn't been changed.

There was a bug that caused the AI to substantially overestimate its military strength. Was fixed in 4-17.
 
Can we have a dedicated option maybe to grant AI gifts, to ensure some additional diplomacy boosts? Just like AI grants you now stuff for free as a gift for the friendship, could player have the same option to do it occasionally? Then maybe the diplomatic boost could be somehow proportionate to the "value" of what was given (expressed like in transparent diplomacy)? Just food for thought, not quite sure if it'd be even possible.
 
Can we have a dedicated option maybe to grant AI gifts, to ensure some additional diplomacy boosts? Just like AI grants you now stuff for free as a gift for the friendship, could player have the same option to do it occasionally? Then maybe the diplomatic boost could be somehow proportionate to the "value" of what was given (expressed like in transparent diplomacy)? Just food for thought, not quite sure if it'd be even possible.

Yeah, that's a very good idea. I sometimes try to give a gift or a favorable deal to AI, but never know if it had any impact (I can usually see the "we traded" green modifier, but I've never seen their attitude improve).

When you give a gift or a "generous offer" with a high deal value (>= 100 IIRC), 1/5 of the deal value is added to recent trade value (capped at 200, or 40 opinion), as opposed to 1/10 normally. This boosts Opinion, which acts as a % modifier to Approach.

Additionally if it's an ongoing deal like GPT, luxuries, strategics, etc. it'll boost the FRIENDLY approach directly. This effect is not capped.

Lastly if they'd be bankrupt without your GPT they're less likely to attack you, since you're keeping them afloat.

So, it does have an effect.
 
is it possible to change diplo scores via lua? this has been a desireable feature on a few modding occasions but never figured out for sure if it could be done (i suspect not)

the specific use case i have in mind is for the enter rival territory flag that remains available but not generally implemented in VP.. most prominently featured in the sub can enter rival territory mod... i wanna check via lua at start of turn or some other regularly occurrence to see if any rival subs are visible within a civ's territory, and decrease their diplo attitude/approach toward the sub owner by some small amount
 
When you give a gift or a "generous offer" with a high deal value (>= 100 IIRC), 1/5 of the deal value is added to recent trade value (capped at 200, or 40 opinion), as opposed to 1/10 normally. This boosts Opinion, which acts as a % modifier to Approach.

Additionally if it's an ongoing deal like GPT, luxuries, strategics, etc. it'll boost the FRIENDLY approach directly. This effect is not capped.

Lastly if they'd be bankrupt without your GPT they're less likely to attack you, since you're keeping them afloat.

So, it does have an effect.
Nice! So when I want to improve relationship with an AI, I should ask how much they'd offer for my luxes or whatever and keep adding stuff until they offer 200 gold (= 5x max opinion improvement of 40) and then give it to them for free?
 
Nice! So when I want to improve relationship with an AI, I should ask how much they'd offer for my luxes or whatever and keep adding stuff until they offer 200 gold (= 5x max opinion improvement of 40) and then give it to them for free?

Code:
GetPlayer()->GetDiplomacyAI()->ChangeRecentTradeValue(eFromPlayer, (iDealValueToMe / 5));
1000 free Gold (or equivalent Deal Value) = 200 Trade Value = 40 Opinion

Unless you have money to burn, you're not going to get the maximum diplo bonus that easily. :)

Although, it might make sense to have the required value scale by era somehow...
 
is it possible to change diplo scores via lua? this has been a desireable feature on a few modding occasions but never figured out for sure if it could be done (i suspect not)

the specific use case i have in mind is for the enter rival territory flag that remains available but not generally implemented in VP.. most prominently featured in the sub can enter rival territory mod... i wanna check via lua at start of turn or some other regularly occurrence to see if any rival subs are visible within a civ's territory, and decrease their diplo attitude/approach toward the sub owner by some small amount

No, but I can get someone more experienced in LUA to add an LUA hook to the Approach and Opinion functions, since that's a desired feature.

I did add the ability to change it via SQL (DiploApproachWeights/DiploOpinionWeights).
 
No, but I can get someone more experienced in LUA to add an LUA hook to the Approach and Opinion functions, since that's a desired feature.

that would be awesome.. i suspect this one change would unlock a good deal of diplo modding potential, if its possible.. custom events etc.

similarly would be great to have lua access to warmonger and war scores.. fingers crossed

the sql additions are nice too, thanks for the update there!
 
that would be awesome.. i suspect this one change would unlock a good deal of diplo modding potential, if its possible.. custom events etc.

similarly would be great to have lua access to warmonger and war scores.. fingers crossed

the sql additions are nice too, thanks for the update there!

Sure, I can do that. :) Not for next version, but it's on my to-do list.

For anyone who's curious as to what I'm up to, I've completed small bugfixes for next version, and am now working on the tedious task of dissecting Firaxis's dumb, terrible, redundant and overcomplicated memory system for the diplomacy AI, by which I mean going through every single memory value and:
- Learning how everything interacts;
- Cleaning up old code and inefficient routines;
- Adding checks for extra stability;
- Preventing overflow of values (there was a bug recently where the # of times Influence with a City-State was lowered would overflow to a negative number);
- Reducing the amount of memory it takes up overall by eliminating unused or unnecessary values (for instance, rather than tracking if something happened AND the turn on when it happened, the turn is all that really needs to be kept track of - and several values are candidates for deletion);
- Fixing various bugs and issues;
- Then testing everything to make sure it doesn't crash and everything works properly.

Replacing the system with one that isn't stupid will come later (hopefully), but for now I'm going to optimize the existing one as much as I can.

When this is done, I'll follow it up with a general cleanup of the code and reorganizing it in a more sensible order (right now there's a lot of functions scattered haphazardly throughout the source code files), along with implementing better logging and debugging for certain functions, namely DoRelationshipPairing and GetBestApproachTowardsMajorCiv.

And when that is done, I'll be in a much better position to make further improvements, including:
- A few requested features, like an option to show number values for opinion modifiers but allow the AI to hide modifiers as well;
- Finally finishing that rework for backstabbing penalties and training the AI to use it intelligently;
- Fixing the code for promises (which has problems, like some penalties remaining forever - I'm also gonna try to add some kind of "promise tracker" to the UI screen at some point if I can, because keeping them in the opinion table takes up a lot of space);
- Better scaling of opinion modifiers based on game speed, having most of them gradually rather than suddenly decay, and additional customization options;
- Major rework for interaction logic with other players (the Firaxis logic is so overcomplicated and inefficiently programmed it hurts, with lots of redundancy and general dumbness); this will take a long time, but when it's done I think players will appreciate it a lot.

I don't have a fixed timeline for when this will get done, but those are my plans for the time being.
 
Last edited:
Awesome work!

One thing I'd really like to see is more meaningful longer-term relationships with civs that you give aid to. It would be great if they could recognise big gifts, propping them up, defending them against enemies etc and actually do what you say if its reasonable. Alliances are one thing, and vassals are another, but something in between those would be awesome.

Another thing I'd love to see is more loaning of gold in exchange for per-turn repayments. While it kind of works at the moment, it would be great if there was more vibrant lending in diplo, where you can essentially invest in other civs in return for gpt (obviously the gpt total would be more than the upfront capital you lend them, hence profit) and the AI asking for loans in tough times, like when at war.
 
Back
Top Bottom