And to complete the exposé, the total list of all relation modifiers that we can have with an AI: (x-post with zyxy - how convenient that I answer his question
)
Factor 0: Team mates
If we're on the same team, it's +100, no more no less. (If it's the barbarian team, it's -100, but that's irrelevant here.) No other factors then apply, but on the other hand the value is then never used for anything, team membership is always checked first.
Factor 1: Base Attitude
The leader's iBaseAttitude, as determined by the leaderhead spreadsheet. This is a value between -1 and 1 (since Gandhi isn't in the game).
Factor 2: Peace weight
All leaders have a base PeaceWeight number defined in the leaderheads XML file, between 0 (Alex, Monty) and 10 (Gandhi). Every leader also rolls a number between 0 and 3 at the start of every game, which is added to the base PeaceWeight, to get the specific PeaceWeight for that game. Two leaders then get a mutual relation modifier towards each other of 4 - abs(PeaceWeight A - PeaceWeight B). In other words, a value between +4 (they have the same number) and -9 (Alex rolled 0 and Gandhi rolled 3). This is the major hidden factor for relations between AIs, and doesn't affect AI-Player relations at all.
Factor 3: Warmonger respect
Warmongering leaders respect each other. All leaders have a Warmonger score, from 0 (peaceful) to 2 (warmonger). Two leaders get a mutual relation modifier towards each other of min(Warmonger A, Warmonger B). This means two full warmongers, say Alex and Monty, have a base +2 towards each other. Alex (2) and Caesar (1) would have +1 towards each other, whereas Caesar (1) and Gandhi (0) or Gandhi and Lizzy (0) would have no extra modifier. This also doesn't affect AI-Player relations.
Factor 4: Handicap modifier
We're on Deity, hence an automatic -1 with all leaders. Note that the AIs don't have this negative, since they all effectively play on Noble.
Factor 5: Team member modifier
If we are on a team with more members than the AI's team, we get the difference in negative modifier. So if we sign a PA with someone, we will have -1 relations with all other AIs (who aren't also PAed to someone).
Factor 6: Rank difference modifier
EDIT: Reworked and corrected.
Each leader has two values governing relations depending on rank: iWorseRankAttitudeChange and iBetterRankAttitudeChange. The former is a value between 0 and -3 and determines how that AI feels about players with
lower higher score, i.e. a jealousy factor. The latter is a value between 0 and 4 and determines how that AI feels about players with a
higher lower score, i.e. a factor of magnanimousity. The actual modifier is [iXXXRankAttitudeChange*iRankDifference/19], where 19 is the total number of civs ever alive +1.
Factor 7: Losers unite
If both we and the AI are on the bottom half in score, we get +1.
Factor 8: Memories of war
If we have "won" a war against the AI, we get a -1 with that AI.
Note that factors 1 through 8 are invisible to us. All the ones that follow will show up in the numbers in the F4 screen:
Factor 9: Close borders spark tensions
This is a negative modifier that depends on the number of workable city tiles that our cultural borders have "stolen" from an AI. The modifier is iCloseBordersAttitudeChange*(40+3*X)/100, where X is the number of tiles stolen up to a maximum of 20 (so the total is never less than iCloseBordersAttitudeChange). This is something that will only ever come into effect with our closest neighbors, i.e. Washington and possibly Asoka (unless their towns get conquered, Yahve forbid), who both have -2. So if we steal 4+ tiles from either of them it's a -1, and if we steal 20+ tiles (not likely) it's a -2.
Factor 10: This war spoils our relationship
If we're at war with the civ, -3 immediately, and another -1 per 5 turns at war, up (or down) to -8 after 25 turns.
Factor 11: Years of peace
+1 after 60 turns of peace.
Factor 12: Brothers and Sisters of the Faith
+1 if we share a religion, +1 more if the other civ has the holy city for that religion, and +1 per 10 turns of sharing that religion up to iSameReligionAttitudeChangeLimit for that leader. For Asoka that number is 7, for Monty it's 2.
Factor 13: Heathens
If we are of different religions we immediately get that leader's iDifferentReligionAttitudeChange, ranging from 0 to -2. -1 more if the other civ has the holy city for their religion, and -1 after 5 turns of different religions, for a total between -1 (no holy city, tolerant) and -4 (holy city, intolerant).
Factor 14: Bonus resources
+1 per 50 turns' worth of exporting resources to that AI (the counter is increased by the number of exports each turn), up to a total of +2.
Factor 15: Open Borders
+1 per 25 turns of Open Borders, up to a total of +2.
Factor 16: Defensive Pact
+1 per 12 turs of Defensive Pact, up to a total of +2.
Factor 17: Rival Defensive Pact
If we don't have a DP with that AI, we get a "We are worried that you have a Defensive Pact with our rivals" negative modifier of 4*(nr of DPs we have)/(nr of other civs alive). So with 16 (all) other civs alive, we would get a -1 modifier per 4 DPs we have. Strangely it doesn't seem to matter if the AI itself has a DP with the same civs.
Factor 18: This war brings us closer together
+1 to relations if we share a war (and are not at war with each other of course). This increases by +1 per 8 turns of shared war, up to that leader's iShareWarAttitudeChangeLimit, ranging from 2 to 4. If either of us sign peace, the initial +1 disappears, but the bonus from the number of turns is remembered, though the memory decreases by 1 per turn.
Factor 19: You have wisely chosen your civics
+1 to relations if both we and the AI have adopted that AI's favorite civic. Also +1 per 10 turns of sharing that civic, up to a total of that leader's iFavoriteCivicAttitudeChangeLimit which ranges from 1 (Saladin) to 5 (Toku and possibly some more) (not 6 since neither Gandhi nor Mao are in this game).
Factor 20: Fair Trade
A complex calculation depending on three things:
1) the total value of all things given for free to that AI: iGrantValue
2) the total value of all things traded to that AI: iTradeValue
3) the number of turns we have known each other: iTurnsKnown
The total bonus is then (iGrantValue + iTradeValue/3)/((iTurnsKnown +1)*5), but capped at +4. In other words this value will deteriorate over time, unless we add more trades to it. The calculations of the values is very involved, but I can list that too if it becomes necessary.
Factor 21: You have traded with our worst enemies
The calculation is very similar to that above, except the constant factor in the divisor is 10 instead of 5. In other words, we can trade twice as much to a worst enemy before we reach a certain modifier, compared to the Fair Trade. Note that the worst enemy can switch, but things added to iGrantValue and iTradeValue never disappear, they only get diluted by passing time.
Factor 22: You declared war on us
This is -3 per time we declare, never disappears or deteriorates.
Factor 23: You declared war on our friend
-1 per time that happens (since Gandhi isn't in the game). Never decays.
Factor 24: You brought a war ally against us
-1 per time it happens, never decays.
Factor 25: You nuked us!
-2 per time it happens, never decays.
Factor 26: You nuked our friend
-1 per time it happens (since Gandhi isn't in the game), never decays.
Factor 27: You razed one of our cities
-2.5 per time it happens (rounded down), never decays.
Factor 28: You razed our holy city
-2 per time it happens, never decays.
Factor 29: Your spy was caught making trouble
-1 per time it happens, except for Cathrine for whom it is -2 per time. Never decays.
Factor 30: You gave us help
+1 per time it happens. Decays with 1/200, i.e. on any given turn there is a 1 chance in 200 that they will forget about one occurence.
Factor 31: You refused to give us help
-1 (or -2 if the leader is Cathrine, Kublai, Louis or Toku) per time it happens, decays with 1/100.
Factor 32: You gave us tribute
+1 per time it happens, decays with 1/50.
Factor 33: You refused to give us tribute
-1 (or -2 if the leader is Cathrine, Kublai, Louis or Toku) per time it happens, decays with 1/150.
Factor 34: You converted to our religion
+1 per time it happens, decays with 1/100.
Factor 35: You refused to convert to our religion
-1 (or -2 if the leader is Cathrine, Kublai, Louis or Toku) per time it happens, decays with 1/50.
Factor 36: You adopted our favorite civic
+1 per time it happens, decays with 1/100.
Factor 37: You refused to adopt our favorite civic
-1 (or -2 if the leader is Cathrine, Kublai, Louis or Toku) per time it happens, decays with 1/50.
Factor 38: You gave us help during war-time
This is weird - there is no modifier for this, even though the AI clearly has a memory counter for it, decaying with 1/150. But for some reason it has no effect on attitude. And it's even more weird since the constructor code for the CvLeaderheadInfo class clearly tries to read that data from the file, even though it isn't there. And it's
even more weird since I could swear that I have seen this modifier at play in the game.
Factor 39: You refused to help us during war-time
-1 (or -2 if the leader is Cathrine, Kublai, Louis or Toku) per time we refuse when the AI asks us to join a war, decays with 1/100.
Factor 40: You stopped trading with our worst enemies
+0.5 per time it happens (which is why we almost never see it in game), decays with 1/100.
Factor 41: You refused to stop trading with our worst enemies
-1 per time it happens, decays with 1/50.
Factor 42: You stopped trading with us
-1 per time it happens, never decays.
Factor 43: You signed a trade embargo against us
-1 per time it happens, never decays.
Factor 44: You made a demand from us
-1 per time it happens up to max -10, never decays.
Factor 45: You have shared you technological discoveries with us
Depending on leader we get between 0.05 (Asoka (!), Bismarck, Isabella and Toku of those that could be in the game) and 0.2 (Mansa, Peter) per tech traded to that AI. Decays with 1/100.
And that's all. Note that a decay means the AI forgets 1
occurence, not 1 less relation modifier (unless it's +/-1 per occurence of course).