Diplomacy Modding Discussion

Posted on Friday, September 18, 2015

A thread for discussing modifying diplomacy and the diplomatic AI, which I've been pissing about with over the last week or so.


Diplo currently works through stacking modifiers. Every turn, the AI has an existing diplomatic relationship score with you from -10 to 10. It also has a huge number of (about 60) triggered modifiers based on various things, like it's relative power to you, how far away you are, what ideology you are etc. These modifiers generally range from 3 to -3 (though there's a few larger). Every turn, the AI totals up all the positive and negative modifiers, and then adjusts it's existing diplomatic relationship score for the next turn by whatever the modifier is. The next turn, it takes it's new DRS and repeats the whole process.


Modifiers are either permanent (we're at war, our ideology is different etc), or time-limited, usually with timings of 25, 50, 75 or 100 turns. They can also be adjusted by AI personality - so you can make spiritual AIs care more about ideological differences, scientific AIs appreciate being given techs more etc.


I suspect there's a diminishing return at play too, but I'm not entirely sure how it works. There's mentions of a delta divisor in the diplomacy section of the AI defs. Possibly someone at SD will be kind enough to enlighten us. Hint, hint


The AI then has various points on it's relationship scale where it becomes willing to do things. So at the top end(8, 9 and 10) you have things like never backstabbing, making alliances etc. At the very low end it stops trading, considers embargoing, and of course warfare.


Finally, there's treaties. Treaties are largely unmoddable in their effects - so, for example, we can't make allies join in a war - but we can change a few things. We can implement a minimum relations score for them to be an available choice in diplo, we can set treaties to have durations or never expire, and we can set them to be either one- or two-way treaties - one-way being where you confer the benefit on the other party, two way being both sides get it. And, of course, we can set how and when they unlock.


The relevant files for diplo are Galciv3AIdefs.xml, DiplomaticActions.xml, DiplomacyDefs.xml, diplomaticmodifiers.xml and Treatydefs.xml. 



A few things spring to mind:


* This means the diplomatic AI has, to some limited extent, got a memory. It not only bases next turns relations on it's present relationship, but also has short-term recollection of events like a military threat through the time-limited modifiers.

* -10 to 10 is a very small range when the smallest modifier integer is 1

* I don't think it's possible to add  in new triggers, so the ones we have are largely all we've got - but there are an awful lot of them.

* The personality modifiers are a wonderful thing.

* It is important to always keep modifier numbers small. The history makes for a relationship that is rarely static - they're either growing to like you more all the time or growing to hate you more.

* If there isn't a diminishing return, then it's quite possible that the AI simply keeps going until it hits the cap in either direction... which would be bad.

* The main problems with treaties are based on the fact that a one-way treaty is usually useless unless your opponent has it, while the AI will always regard a two-way treaty as you offering it something.