Diplo AI - Approach Calculation (4-7 Beta Patch)

Recursive

Already Looping
Moderator
Supporter
Joined
Dec 19, 2017
Messages
4,782
Location
Antarctica
Since there's been a fair amount of discussion about AI aggression going on, I figured I might as well post the approach calculation.

The approach calculation is how the AI decides whether to plan WAR or be HOSTILE, GUARDED, DECEPTIVE, AFRAID, FRIENDLY or NEUTRAL towards other players.

This code is for the 4-7 beta patch version, after my recent improvements, fixes and changes to AI aggression, so it is not reflective of 3-15-2 and any earlier versions.

However, you might still have thoughts on it - feel free to share. :)

This thread is intended specifically for comments on the AI's approach selection.

General diplomacy feedback on other things can be posted in the dedicated thread: https://forums.civfanatics.com/threads/diplomacy-ai-development.655040/

---------

Normal Approach Calculation
This calculation is used when updating Approach for most players (special cases are covered in the next section).

For a list of civs and their approach biases, see here: https://civ-5-cbp.fandom.com/wiki/Detailed_Guide_to_Diplomacy#Approach_Biases

Keep in mind approach biases range from 1 to 10, and are randomized by +/- 2 each game. The bias value can go above 10 from the randomization but cannot go below 1.

Here is the approach calculation for the 4-7 beta patch version, written in pseudocode:
Code:
[NOTES ON CERTAIN VARIABLES]

DIPLO TYPE
- At game start, each AI civ is assigned a Diplo Type: CONQUEROR, DIPLOMAT, CULTURAL or SCIENTIFIC.
- This is dependent on the leader's randomized flavors (e.g. leaders with high Offense flavors are more likely to pick CONQUEROR). Weight is also added based on the leader's UA.
- Diplo Type affects which victory condition the AI leader will be extra sensitive to for the current game, and is used several times in this approach function.
- AI civs replacing a human player in MP don't have a Diplo Type and thus, don't use this mechanic.

VICTORY COMPETITION
- The player can disable the AI's victory competitiveness in DiploAIOptions.sql by setting DIPLO_AI_NO_VICTORY_COMPETITION to 1.
- This causes the AI not to apply penalties based on the other player's progress towards winning the game.
- Once the game has been won, victory competition is disabled automatically.

ERA
- For the purposes of the approach function, the Era is 0 in the Ancient Era, 1 in the Classical Era, 2 in the Medieval Era, and so on.
- "Our era" means the evaluating AI player's current era.
- "Their era" means the evaluated player's current era.

BACKSTABBER PENALTY

The AI regularly tests players to determine if they are a "backstabber". Backstabbing penalties can occur if you:
- Break a Declaration of Friendship with a player;
- Denounce a player you're friends with;
- Declare war on a player you're friends with;
- Break a promise not to declare war on a player;
- Break a promise not to conquer a player's protected City-State;
- Declare war on one of your vassals.

AIs will ALSO view you as a backstabber if you've captured their original capital or Holy City (unless they're your capitulated vassal), although only their teammates will agree with this view.

Backstabbing a player can result in global penalties, depending on the severity of the backstabbing and the other AIs' relationships with that player.

Backstabbing penalties do not always occur (for instance, the AI will not care if you declare war on someone who backstabbed them).
They will eventually expire after a number of turns, depending on game speed.

If the AI considers you a "backstabber", or considers anyone on your team a "backstabber", it has a number of negative approach changes throughout this function.


//////////////////////////////////////////////////////
What is the best approach to take towards this player?
Run through the following steps in order.
//////////////////////////////////////////////////////


[PART 1: INITIAL WEIGHTS]


All seven approach scores start at 0.


1. Base Personality Weight

Begin by adding 1x our bias for each approach to our score for that approach.


2. Default Neutral Weight

Add our NEUTRAL bias to the NEUTRAL approach.


3. Last Turn Approach Biases

If our approach last turn was WAR and our war goal towards this player last turn was PREPARE (building up) or CONQUEST (destroy them completely), add our WAR bias to the WAR approach.

If our approach last turn was HOSTILE and we were preparing to demand from this player last turn, add our HOSTILE bias to the HOSTILE approach.


4. Domination Victory Bias

If we're not at war with this player, or we are at war and it's a stalemate or better (GetWarState function), and one of the following is true:
- Our Diplo Type is CONQUEROR, or;
- We're going for a Domination Victory.

... then add our WAR bias to the WAR approach.


5. Easy Target
If these conditions are met:
- We consider this player an easy target;
- We're at war with them already OR we're not at war with any major civilizations.

Then they're considered an "easy target" for the rest of this approach calculation.

If they're an easy target:
- Add our WAR bias to the WAR approach.


6. City-State War Quests

For each City-State that has a quest for us to:
- Declare war on this player, or;
- Liberate a city this player owns, or;
- Capture a city this player owns;

Add one to the war quest counter.

Double the war quest counter if our Diplo Type is DIPLOMAT.

If the war quest counter is above 0, then add our WAR bias plus the war quest counter to the WAR approach.


[PART 2: FRIENDSHIP MODS]


7. Declaration of Friendship

If we currently have a Declaration of Friendship with this player:
- Add our FRIENDLY bias to the FRIENDLY approach.
- Set our WAR approach score to 0.
- Set our HOSTILE approach score to 0.


8. Defensive Pact

If we currently have a Defensive Pact with this player:
- Add our FRIENDLY bias to the FRIENDLY approach.
- Set our WAR approach score to 0.
- Set our HOSTILE approach score to 0.


9. Research Agreement

If we currently have a research agreement with this player:
- Add our FRIENDLY bias to the FRIENDLY approach.
- Set our WAR approach score to 0.
- Set our HOSTILE approach score to 0.


10. Coop War History

Check how many times this player refused to go on a coop war with us.
+1 for each time they refused the request
+2 for each time they refused the request by warning the target AI
+2 for each time they broke a promise to start a coop war with us
-1 for each time they accepted the request and we went to war together

Note #1: The memory value tracking this is set to 0 for both players if one of them capitulates to the other.

Note #2: If one player resurrects the other, then the value is set to 0 for both players *if positive* (bad).

If the total is positive:
- Add our DECEPTIVE bias plus the total to the DECEPTIVE approach.

If the total is negative:
- Add our FRIENDLY bias to the FRIENDLY approach.
- Subtract the total from the FRIENDLY approach (since it's negative; the sign is flipped).


11. Coop War Soon

If we promised to start a coop war with this player against at least one third party:
- Multiply our FRIENDLY bias by the number of coop wars we promised to start with this player, and add that to the FRIENDLY approach.
- Set our WAR approach score to 0.
- Set our HOSTILE approach score to 0.

NOTE: Coop war promises between two players are cancelled if a DoF is ended early via the Discuss menu, or the players denounce/go to war with each other.


12. Liberated Cities

If this player has liberated some of our cities, and all of the following conditions are true:
- We don't view this player as a backstabber (see explanation on backstabbing penalties above).
- This player has not captured our original capital.
- This player has not captured our Holy City.

Then:
- Add our FRIENDLY bias plus the number of our cities they've liberated to the FRIENDLY approach.
- Set our WAR approach score to 0.
- Set our HOSTILE approach score to 0.
- Set our DECEPTIVE approach score to 0.


13. Resurrection

If this player resurrected us OR we resurrected them ("You restored their civilization after they were annihilated!"):
- Add our FRIENDLY bias to the FRIENDLY approach.
- Set all other approaches to -1x their approach bias value.

If BOTH of us resurrected each other, then:
- Add our FRIENDLY bias to the FRIENDLY approach again.
- Subtract an additional -1x approach bias value from all other approaches.


[PART 3: PROVOCATIONS]


14. Denouncements

We've currently denounced this player!
- Add our WAR bias to the WAR approach.
- Add our HOSTILE bias to the HOSTILE approach.
- Set our FRIENDLY approach score to 0.

This player has currently denounced us!
- Add our GUARDED bias to the GUARDED approach.
- Set our FRIENDLY approach score to 0.


15. Backstabbers

If we consider this player a backstabber:
- Add our WAR bias to the WAR approach.
- Add our HOSTILE bias to the HOSTILE approach.
- Add our GUARDED bias to the GUARDED approach.
- Set our FRIENDLY approach score to 0.

If this player is untrustworthy *and* personally betrayed us by:
- Denouncing us while we had a Declaration of Friendship, OR
- Declaring war on us while we had a Declaration of Friendship, OR
- Broke a military promise not to declare war on us, OR
- Broke a promise not to conquer our protected City-State, OR
- Declared war on us while we were their vassal...

Then, apply extra penalties:
- Add 2x our WAR bias to the WAR approach.
- Add 2x our HOSTILE bias to the HOSTILE approach.
- Add 2x our GUARDED bias to the GUARDED approach.


16. Captured Our Major Cities

Skip this check if we're this player's capitulated vassal.

If this player currently owns our original capital:
- Add 2x our WAR bias to the WAR approach.
- Add 2xour HOSTILE bias to the HOSTILE approach.
- Add 2x our GUARDED bias to the GUARDED approach.

If this player currently owns our Holy City:
- Add 2x our WAR bias to the WAR approach.
- Add 2x our HOSTILE bias to the HOSTILE approach.
- Add 2x our GUARDED bias to the GUARDED approach.

If this player is an easy target:
- And they currently own our original capital, add 100 to the WAR approach.
- And they currently own our Holy City, add 5x our WAR bias to the WAR approach.

*NOTE:* Using an Inquisitor on the Holy City to remove its Holy City status will clear the associated penalties.


17. Stolen Territory

If this player has stolen our territory *DURING PEACETIME* with a Great General or America's UA:
- Add our WAR bias plus the number of thefts to the WAR approach.
- Add our HOSTILE bias plus the number of thefts to the HOSTILE approach.

  If they're an easy target:
  - Add 2x our WAR bias to the WAR approach.

NOTE: The number of thefts is reset to 0 for both players when war is declared between them.
Stealing territory while at war does not accrue diplomatic penalties.


18. Attacks on Protected City-States

If this player killed one of our protected City-States within the past 50 turns:
- Add 2x our WAR bias to the WAR approach.
- Add 2x our HOSTILE bias to the HOSTILE approach.
- Set our FRIENDLY approach score to 0.

If they haven't killed any recently, but they *have* attacked one of our protected City-States within the past 30 turns:

  If they have EVER killed one of our protected City-States:
  - Add our WAR bias to the WAR approach.
  - Add our HOSTILE bias to the HOSTILE approach.
  - Set our FRIENDLY approach score to 0.

  Otherwise:
  - Add our HOSTILE bias to the HOSTILE approach.
  - Add our GUARDED bias to the GUARDED approach.


19. Captured Cities

Skip this check if their proximity from us is FAR or DISTANT.

Otherwise, count how many cities we've captured from them, and how many they've captured from us.
Subtract our conquests from their conquests to get the "difference of cities".

NOTE: The captured city count is reset for both players if either player resurrects the other.

If we've captured more cities from them than they've captured from us, check their military strength:

  If they're an easy target:
  - Add our WAR bias plus 2x the difference of cities to the WAR approach.
  - Add our HOSTILE bias plus 2x the difference of cities to the HOSTILE approach.

  Otherwise, if their military strength compared to us is AVERAGE or weaker:
  - Add our WAR bias plus the difference of cities to the WAR approach.
  - Add our HOSTILE bias plus the difference of cities to the HOSTILE approach.

  Otherwise, if they're not our capitulated vassal, expect revenge:
  - Add our GUARDED bias plus the difference of cities to the GUARDED approach.

If they've captured more cities from them than we've captured from them, check their military strength:

  Skip this check if we're their vassal, UNLESS they have previously declared war on one of their own vassals.

  Multiply the difference of cities by -1 (flip the sign).

  If they're an easy target:
  - Add our WAR bias plus 2x the difference of cities to the WAR approach.
  - Add our HOSTILE bias plus 2x the difference of cities to the HOSTILE approach.

  Otherwise, if their military strength compared to us is below AVERAGE:
  - Add our WAR bias plus the difference of cities to the WAR approach.
  - Add our HOSTILE bias plus the difference of cities to the HOSTILE approach.

  Otherwise:
  - Subtract our WAR bias plus the difference of cities from the WAR approach.
  - Subtract our HOSTILE bias plus the difference of cities from the HOSTILE approach.
  - Add our GUARDED bias plus the difference of cities to the GUARDED approach.


[PART 4: KEY PLAYERS]

20. Biggest and Major Competitors

If this player is our biggest competitor (> 18 competitor weight, highest competitor weight of all major civs):
- Add 2x our WAR bias to the WAR approach.
- Add 2x our HOSTILE bias to the HOSTILE approach.

  If they're also an easy target:
  - Add 2x our WAR bias to the WAR approach.

Otherwise, if this player is a major competitor of ours (IsMajorCompetitor function):
- Add our WAR bias to the WAR approach.
- Add our DECEPTIVE bias to the DECEPTIVE approach.

  If they're also an easy target:
  - Add our WAR bias to the WAR approach.

Otherwise, they're NOT a major competitor, so:
- Add our FRIENDLY bias to the FRIENDLY approach.
- Add our NEUTRAL bias to the NEUTRAL approach.


21. Most Valuable DoF

If this player is our most valuable DoF (> 32 DoF weight, and more than all other civs), then:
- Add 2x our FRIENDLY bias to the FRIENDLY approach.

Otherwise, if this player is our most valuable DoF *EXCLUDING OUR CURRENT FRIENDS*:
- Add our FRIENDLY bias to the FRIENDLY approach.


22. Most Valuable DP

Skip this check if we do not have shared embassies, or Defensive Pact trading with this team is not allowed.

If this player is our most valuable DP (> 18 DP weight, and more than all other civs), then:
- Add 2x our FRIENDLY bias to the FRIENDLY approach.

Otherwise, if this player is our most valuable DP *EXCLUDING OUR CURRENT DPs*:
- Add our FRIENDLY bias to the FRIENDLY approach.


23. Relations to Other Key Players

Loop through all other valid major civs (not on our team, not on their team, not unmet, not dead, > 0 cities).

If they're at war with the other player:

  If the other player is our biggest competitor:
  - Add our FRIENDLY bias to the FRIENDLY approach.

  Otherwise, if the other player is our most valuable DoF:
  - Add our WAR bias to the WAR approach.
  - Add our HOSTILE bias to the HOSTILE approach.

  Otherwise, if the other player is our most valuable DP (and we have shared embassies with that player, and Defensive Pact trading with them is allowed):
  - Add our WAR bias to the WAR approach.
  - Add our HOSTILE bias to the HOSTILE approach.

Otherwise, if they have a Defensive Pact with the other player, and the other player's military strength compared to us is AVERAGE or stronger:
- Add our DECEPTIVE bias to the DECEPTIVE approach.
- Subtract our WAR bias from the WAR approach.
- Subtract our HOSTILE bias from the HOSTILE approach.


[PART 5: EVALUATIONS]


24. Military Threat

What is this player's military threat level? (GetMilitaryThreat function)

CRITICAL
- Add 2x our AFRAID bias to the AFRAID approach.

SEVERE
- Add our AFRAID bias to the AFRAID approach.
- Add our GUARDED bias to the GUARDED approach.

MAJOR
- Add our GUARDED bias to the GUARDED approach.
- Add our DECEPTIVE bias to the DECEPTIVE approach.

MINOR
- Add our NEUTRAL bias to the NEUTRAL approach.
- Add our DECEPTIVE bias to the DECEPTIVE approach.

NONE
- Add our FRIENDLY bias to the FRIENDLY approach.


25. Warmonger Threat

What is this player's warmonger threat level? (GetWarmongerThreat function)

CRITICAL
- Add our WAR bias to the WAR approach.
- Add our AFRAID bias to the AFRAID approach.
- Add our HOSTILE bias to the HOSTILE approach.

SEVERE
- Add our WAR bias to the WAR approach.
- Add our GUARDED bias to the GUARDED approach.
- Add our HOSTILE bias to the HOSTILE approach.

MAJOR
- Add our GUARDED bias to the GUARDED approach.
- Add our DECEPTIVE bias to the DECEPTIVE approach.

MINOR
- Add our NEUTRAL bias to the NEUTRAL approach.
- Add our DECEPTIVE bias to the DECEPTIVE approach.

NONE
- Add our FRIENDLY bias to the FRIENDLY approach.


26. Military Strength Compared To Us

What is this player's military strength compared to us? (GetPlayerMilitaryStrengthComparedToUs function)

IMMENSE
- Add 4x our AFRAID bias to the AFRAID approach.
- Subtract 3x our WAR bias from the WAR approach.
- Subtract 3x our HOSTILE bias from the HOSTILE approach.

POWERFUL
- Add our FRIENDLY bias to the FRIENDLY approach.
- Add our GUARDED bias to the GUARDED approach.
- Add 2x our AFRAID bias to the AFRAID approach.
- Subtract 2x our WAR bias from the WAR approach.
- Subtract 2x our HOSTILE bias from the HOSTILE approach.

STRONG
- Add our NEUTRAL bias to the NEUTRAL approach.
- Add our FRIENDLY bias to the FRIENDLY approach.
- Subtract our WAR bias from the WAR approach.
- Subtract our HOSTILE bias from the HOSTILE approach.

AVERAGE
- Add our NEUTRAL bias to the NEUTRAL approach.
- Add our FRIENDLY bias to the FRIENDLY approach.

POOR
- Add our DECEPTIVE bias to the DECEPTIVE approach.
- Add our NEUTRAL bias to the NEUTRAL approach.
- Subtract our AFRAID bias from the AFRAID approach.
- Subtract our GUARDED bias from the GUARDED approach.

WEAK
- Add our WAR bias to the WAR approach.
- Add our HOSTILE bias to the HOSTILE approach.
- Subtract 2x our AFRAID bias from the AFRAID approach.
- Subtract 2x our GUARDED bias from the GUARDED approach.

PATHETIC
- Add 2x our WAR bias to the WAR approach.
- Add 2x our HOSTILE bias to the HOSTILE approach.
- Subtract 3x our AFRAID bias from the AFRAID approach.
- Subtract 3x our GUARDED bias from the GUARDED approach.


27. Economic Strength Compared To Us

What is this player's economic strength compared to us? (GetPlayerEconomicStrengthComparedToUs function)

IMMENSE
- Add 4x our AFRAID bias to the AFRAID approach.
- Subtract 3x our WAR bias from the WAR approach.
- Subtract 3x our HOSTILE bias from the HOSTILE approach.

POWERFUL
- Add our FRIENDLY bias to the FRIENDLY approach.
- Add our GUARDED bias to the GUARDED approach.
- Add 2x our AFRAID bias to the AFRAID approach.
- Subtract 2x our WAR bias from the WAR approach.
- Subtract 2x our HOSTILE bias from the HOSTILE approach.

STRONG
- Add our NEUTRAL bias to the NEUTRAL approach.
- Add our FRIENDLY bias to the FRIENDLY approach.
- Subtract our WAR bias from the WAR approach.
- Subtract our HOSTILE bias from the HOSTILE approach.

AVERAGE
- Add our NEUTRAL bias to the NEUTRAL approach.
- Add our FRIENDLY bias to the FRIENDLY approach.

POOR
- Add our DECEPTIVE bias to the DECEPTIVE approach.
- Add our NEUTRAL bias to the NEUTRAL approach.
- Subtract our AFRAID bias from the AFRAID approach.
- Subtract our GUARDED bias from the GUARDED approach.

WEAK
- Add our WAR bias to the WAR approach.
- Add our HOSTILE bias to the HOSTILE approach.
- Subtract 2x our AFRAID bias from the AFRAID approach.
- Subtract 2x our GUARDED bias from the GUARDED approach.

PATHETIC
- Add 2x our WAR bias to the WAR approach.
- Add 2x our HOSTILE bias to the HOSTILE approach.
- Subtract 3x our AFRAID bias from the AFRAID approach.
- Subtract 3x our GUARDED bias from the GUARDED approach.


28. DoF Level

What is our DoF Level with this player? (GetDoFType function)

DoF Level starts at NEW and is set to UNTRUSTWORTHY if a DoF is broken, or there is a denouncement/DoW in either direction.

Every time a DoF is signed, DoF Level advances as follows based on the old level:
UNTRUSTWORTHY or NEW -> FRIENDS
FRIENDS -> ALLIES
ALLIES -> BATTLE BROTHERS (highest level)

If DoF Level is...

UNTRUSTWORTHY
- Add our WAR bias plus our Era to the WAR approach.
- Add our GUARDED bias plus our Era to the GUARDED approach.
- Add our HOSTILE bias plus our Era to the HOSTILE approach.

NEW
- Add our NEUTRAL bias plus our Era to the NEUTRAL approach.
- Add our FRIENDLY bias plus our Era to the FRIENDLY approach.

FRIENDS
- Add our FRIENDLY bias plus our Era to the FRIENDLY approach.
- Subtract our DECEPTIVE bias plus our Era from the DECEPTIVE approach.

ALLIES
- Add our FRIENDLY bias plus 2x our Era to the FRIENDLY approach.
- Subtract our DECEPTIVE bias plus 2x our Era from the DECEPTIVE approach.

BATTLE BROTHERS
- Add our FRIENDLY bias plus 3x our Era to the FRIENDLY approach.
- Subtract our DECEPTIVE bias plus 3x our Era from the DECEPTIVE approach.


29. Victory Dispute Level

How competitive are we over the same victory condition? (GetVictoryDisputeLevel function)

Skip this check if the game turn is 150 or less, or victory competition is disabled.

(NOTE: Vassals do not compete for victory.)

FIERCE COMPETITION
Opinion Indicator: "They know you are competing with them, and they hate it!"
- Add our GUARDED bias plus their era to the GUARDED approach.
- Add our HOSTILE bias plus their era to the HOSTILE approach.
- Add our WAR bias plus their era to the WAR approach.

STRONG COMPETITION
Opinion Indicator: "They suspect you are competing with them."
- Add our DECEPTIVE bias plus their era to the DECEPTIVE approach.
- Add our GUARDED bias plus their era to the GUARDED approach.
- Add our WAR bias plus their era to the WAR approach.

WEAK COMPETITION
Opinion Indicator: "They fear you are competing with them."
- Add our NEUTRAL bias plus their era to the NEUTRAL approach.
- Add our DECEPTIVE bias plus their era to the DECEPTIVE approach.

NO COMPETITION
- Add our FRIENDLY bias plus their era to the FRIENDLY approach.
- Add our NEUTRAL bias plus their era to the NEUTRAL approach.


30. Victory Block Level

How much do we want to stop this player from winning? (GetVictoryBlockLevel function; the farther you are in the lead, the more they hate you)

Skip this check if the game turn is 150 or less, or victory competition is disabled.

(NOTE: Vassals do not compete for victory.)

(NOTE #2: If Opinion of this major civ is FRIEND or ALLY, no victory block penalties are applied.)

FIERCE DESIRE
Opinion Indicator: "Your behavior infuriates them."
- Add our GUARDED bias plus their era to the GUARDED approach.
- Add our HOSTILE bias plus their era to the HOSTILE approach.
- Add our WAR bias plus their era to the WAR approach.

STRONG DESIRE
Opinion Indicator: "Your behavior angers them."
- Add our DECEPTIVE bias plus their era to the DECEPTIVE approach.
- Add our GUARDED bias plus their era to the GUARDED approach.
- Add our WAR bias plus their era to the WAR approach.

WEAK DESIRE
Opinion Indicator: "Your behavior worries them."
- Add our NEUTRAL bias plus their era to the NEUTRAL approach.
- Add our DECEPTIVE bias plus their era to the DECEPTIVE approach.

NO DESIRE
- Add our FRIENDLY bias plus their era to the FRIENDLY approach.
- Add our NEUTRAL bias plus their era to the NEUTRAL approach.


31. Land Dispute Level

How much do we covet their lands? (GetLandDisputeLevel function)

MULTIPLIER begins at 1.
BONUS begins set to true. (territorial disputes are always important!)
VICTORY CONCERN begins set to false.

If our Diplo Type is CONQUEROR or our UA grants war bonuses:
- Increase MULTIPLIER by 1.

If our era is Ancient or Classical:
- Increase MULTIPLIER by 1.

If our era is Medieval+ and we're going for a Domination Victory:
- Increase MULTIPLIER by 1.
- Set VICTORY CONCERN to true.

If we're close to a Domination Victory:
- Increase MULTIPLIER by 1.
- Set VICTORY CONCERN to true.

If the other player is a reckless expander:
- Increase MULTIPLIER by 1.
- Set BONUS to false.

If victory competition is enabled, add the number of vassals and the number of capitals the other player possesses together.

  If the sum of these is greater than 2 OR they're close to a Domination Victory:
  - Increase MULTIPLIER by 1.
  - Set BONUS to false.

- Land Dispute Check -

Opinion Indicator if WEAK or above: "Territorial disputes strain your relationship."
Opinion Indicator if NONE: "You have no contested borders."

NO DISPUTE
(Only apply a bonus here if BONUS is set to true.)
- Multiply our FRIENDLY bias by the MULTIPLIER, and add that to the FRIENDLY approach.
- Multiply our NEUTRAL bias by the MULTIPLIER, and add that to the NEUTRAL approach.

WEAK DISPUTE
- If Victory Concern is true OR our Diplo Type is CONQUEROR OR our UA grants war bonuses, multiply our WAR bias by the MULTIPLIER, and add that to the WAR approach.
- Multiply our GUARDED bias by the MULTIPLIER, and add that to the GUARDED approach.
- Multiply our DECEPTIVE bias by the MULTIPLIER, and add that to the DECEPTIVE approach.

STRONG DISPUTE
- Multiply our WAR bias by the MULTIPLIER, and add that to the WAR approach.
- Multiply our GUARDED bias by the MULTIPLIER, and add that to the GUARDED approach.
- Multiply our HOSTILE bias by the MULTIPLIER, and add that to the HOSTILE approach.

FIERCE DISPUTE
- If Victory Concern is true, double the multiplier. If false, but our Diplo Type is CONQUEROR OR our UA grants war bonuses, increase multiplier by 1.
- Multiply our WAR bias by the multiplier, and add that to the WAR approach.
- Multiply our HOSTILE bias by the multiplier, and add that to the HOSTILE approach.



32. City-State Dispute Level

How much are we competing with this player for the favor of the same City-States? (GetMinorCivDisputeLevel function)

NOTE: This check is only calculated if the AI has met at least one City-State who is still alive.
If there are no living City-States in the game, or they haven't met any, no bonus or penalty will be added for this.

MULTIPLIER begins at 1.
BONUS begins set to false.
VICTORY CONCERN begins set to false.

If our Diplo Type is DIPLOMAT or our UA grants diplomacy bonuses:
- Increase MULTIPLIER by 1.
- Set BONUS to true.

If our era is Renaissance+ and we're going for a Diplomatic Victory:
- Increase MULTIPLIER by 1.
- Set BONUS to true.
- Set VICTORY CONCERN to true.

If we're close to a Diplomatic Victory:
- Increase MULTIPLIER by 1.
- Set BONUS to true.
- Set VICTORY CONCERN to true.

If they're close to a Diplomatic Victory and victory competition is enabled:
- Increase MULTIPLIER by 1.
- Set BONUS to false.
- Set VICTORY CONCERN to true.

If they have a diplomatic penalty for performing a City-State coup against us:
- Increase MULTIPLIER by 1.
- Set BONUS to false.

If they've recently attacked (30 turns) or killed (50 turns) our protected City-States, or broke/ignored a promise not to conquer our protected City-State:
- Increase MULTIPLIER by 1.
- Set BONUS to false.

- City-State Dispute Check -

Opinion Indicator if WEAK or above: "You are competing for the favor of the same City-States!"
Opinion Indicator if NONE: "You are not competing for the favor of the same City-States." (only if Diplo Type is DIPLOMAT and no City-State coup penalty)

NO DISPUTE
(Only apply a bonus here if BONUS is set to true.)
- Multiply our FRIENDLY bias by the MULTIPLIER, and add that to the FRIENDLY approach.
- Multiply our NEUTRAL bias by the MULTIPLIER, and add that to the NEUTRAL approach.

WEAK DISPUTE
- If Victory Concern is true OR our Diplo Type is DIPLOMAT OR our UA grants diplomacy bonuses, multiply our WAR bias by the MULTIPLIER, and add that to the WAR approach.
- Multiply our GUARDED bias by the MULTIPLIER, and add that to the GUARDED approach.
- Multiply our DECEPTIVE bias by the MULTIPLIER, and add that to the DECEPTIVE approach.

STRONG DISPUTE
- Multiply our WAR bias by the MULTIPLIER, and add that to the WAR approach.
- Multiply our GUARDED bias by the MULTIPLIER, and add that to the GUARDED approach.
- Multiply our HOSTILE bias by the MULTIPLIER, and add that to the HOSTILE approach.

FIERCE DISPUTE
- If Victory Concern is true, double the multiplier. If false, but our Diplo Type is DIPLOMAT OR our UA grants diplomacy bonuses, increase multiplier by 1.
- Multiply our WAR bias by the multiplier, and add that to the WAR approach.
- Multiply our HOSTILE bias by the multiplier, and add that to the HOSTILE approach.



33. Wonder Dispute Level

How much are we competing with this player for World Wonders? (GetWonderDisputeLevel function)

MULTIPLIER begins at 1.
BONUS begins set to false.
VICTORY CONCERN begins set to false.

If our Diplo Type is CULTURAL or our UA grants cultural bonuses:
- Increase MULTIPLIER by 1.
- Set BONUS to true.

If our era is Renaissance+ and we're going for a Culture Victory:
- Increase MULTIPLIER by 1.
- Set BONUS to true.
- Set VICTORY CONCERN to true.

If we're close to a Culture Victory:
- Increase MULTIPLIER by 1.
- Set BONUS to true.
- Set VICTORY CONCERN to true.

If they're close to a Culture Victory and victory competition is enabled:
- Increase MULTIPLIER by 1.
- Set BONUS to false.
- Set VICTORY CONCERN to true.

If their Influence Level over us is INFLUENTIAL or DOMINANT:
- Increase MULTIPLIER by 1.
- Set BONUS to false.

If their Influence Level over us is POPULAR and their Influence Trend is RISING:
- Increase MULTIPLIER by 1.
- Set BONUS to false.

If this player is a wonder spammer:
- Increase MULTIPLIER by 1.
- Set BONUS to false.

- Wonder Dispute Check -

Opinion Indicator if WEAK or above: "You are competing for World Wonders."
Opinion Indicator if NONE: "You are not competing for World Wonders." (only if Diplo Type is CULTURAL and no wonder spammer penalty)

NO DISPUTE
(Only apply a bonus here if BONUS is set to true.)
- Multiply our FRIENDLY bias by the MULTIPLIER, and add that to the FRIENDLY approach.
- Multiply our NEUTRAL bias by the MULTIPLIER, and add that to the NEUTRAL approach.

WEAK DISPUTE
- If Victory Concern is true OR our Diplo Type is CULTURAL OR our UA grants cultural bonuses, multiply our WAR bias by the MULTIPLIER, and add that to the WAR approach.
- Multiply our GUARDED bias by the MULTIPLIER, and add that to the GUARDED approach.
- Multiply our DECEPTIVE bias by the MULTIPLIER, and add that to the DECEPTIVE approach.

STRONG DISPUTE
- Multiply our WAR bias by the MULTIPLIER, and add that to the WAR approach.
- Multiply our GUARDED bias by the MULTIPLIER, and add that to the GUARDED approach.
- Multiply our HOSTILE bias by the MULTIPLIER, and add that to the HOSTILE approach.

FIERCE DISPUTE
- If Victory Concern is true, double the multiplier. If false, but our Diplo Type is CULTURAL OR our UA grants cultural bonuses, increase multiplier by 1.
- Multiply our WAR bias by the multiplier, and add that to the WAR approach.
- Multiply our HOSTILE bias by the multiplier, and add that to the HOSTILE approach.



34. Tech Competition Level

How far ahead or behind are they in technology? (GetTechDisputeLevel function)

MULTIPLIER begins at 1.
BONUS begins set to false.
VICTORY CONCERN begins set to false.

If our Diplo Type is SCIENTIFIC or our UA grants scientific bonuses:
- Increase MULTIPLIER by 1.
- Set BONUS to true.

If our era is Renaissance+ and we're going for a Science Victory:
- Increase MULTIPLIER by 1.
- Set BONUS to true.
- Set VICTORY CONCERN to true.

If we're close to a Science Victory:
- Increase MULTIPLIER by 1.
- Set BONUS to true.
- Set VICTORY CONCERN to true.

If they're close to a Science Victory and victory competition is enabled:
- Increase MULTIPLIER by 1.
- Set BONUS to false.
- Set VICTORY CONCERN to true.

If they have a diplomatic penalty for spying on us (a broken/ignored promise counts for this):
- Increase MULTIPLIER by 1.
- Set BONUS to false.

- Tech Competition Check -

Opinion Indicator if WEAK or above: "You are competing for technological advancement." (only if Diplo Type is SCIENTIFIC)
Opinion Indicator if NONE: "You are not competing for technological advancement." (only if Diplo Type is SCIENTIFIC)

NO DISPUTE (0 or less techs ahead)
(Only apply a bonus here if BONUS is set to true.)
- Multiply our FRIENDLY bias by the MULTIPLIER, and add that to the FRIENDLY approach.
- Multiply our NEUTRAL bias by the MULTIPLIER, and add that to the NEUTRAL approach.

WEAK DISPUTE (1 or 2 techs ahead)
- If Victory Concern is true OR our Diplo Type is SCIENTIFIC OR our UA grants scientific bonuses, multiply our WAR bias by the MULTIPLIER, and add that to the WAR approach.
- Multiply our GUARDED bias by the MULTIPLIER, and add that to the GUARDED approach.
- Multiply our DECEPTIVE bias by the MULTIPLIER, and add that to the DECEPTIVE approach.

STRONG DISPUTE (3 or 4 techs ahead)
- Multiply our WAR bias by the MULTIPLIER, and add that to the WAR approach.
- Multiply our GUARDED bias by the MULTIPLIER, and add that to the GUARDED approach.
- Multiply our HOSTILE bias by the MULTIPLIER, and add that to the HOSTILE approach.

FIERCE DISPUTE (5 or more techs ahead, or has built spaceship parts)
- If Victory Concern is true, double the multiplier. If false, but our Diplo Type is SCIENTIFIC OR our UA grants scientific bonuses, increase multiplier by 1.
- Multiply our WAR bias by the multiplier, and add that to the WAR approach.
- Multiply our HOSTILE bias by the multiplier, and add that to the HOSTILE approach.



35. War Projection

How well do we a think a war against this player would go? (GetWarProjection function)
Estimated consequences of the war for us:

VERY GOOD
- Add 2x our WAR bias to the WAR approach.
- Add 2x our HOSTILE bias to the HOSTILE approach.

GOOD
- Add our DECEPTIVE bias to the DECEPTIVE approach.
- Add our WAR bias to the WAR approach.

STALEMATE or UNKNOWN
- Add our NEUTRAL bias to the NEUTRAL approach.

DEFEAT
- Add our AFRAID bias to the AFRAID approach.
- Add our GUARDED bias to the GUARDED approach.

DESTRUCTION
- Add 2x our AFRAID bias to the AFRAID approach.
- Add our FRIENDLY bias to the FRIENDLY approach.


36. Target Value

Our assessment of this player's value as a military target (based on overall strength estimate) (GetPlayerTargetValue function)

SOFT
- Add 2x our HOSTILE bias to the HOSTILE approach.
- Add 2x our WAR bias to the WAR approach.

FAVORABLE
- Add our DECEPTIVE bias to the DECEPTIVE approach.
- Add our WAR bias to the WAR approach.

AVERAGE
- Add our NEUTRAL bias to the NEUTRAL approach.
- Add our DECEPTIVE bias to the DECEPTIVE approach.

BAD
- Add our FRIENDLY bias to the FRIENDLY approach.
- Add our NEUTRAL bias to the NEUTRAL approach.

IMPOSSIBLE
- Add our FRIENDLY bias to the FRIENDLY approach.


37. Military Aggressive Posture

How much threat is posed by their military deployment near our borders? (GetMilitaryAggressivePosture function)

*Note:* Aggressive posture is NONE if they've given you Open Borders, you resurrected them, or you have a Declaration of Friendship or Defensive Pact with them.

HIGH or INCREDIBLE
Opinion Indicator: "Your military deployment is extremely threatening."
- Add our HOSTILE bias to the HOSTILE approach.
- Add our WAR bias to the WAR approach.

MEDIUM
Opinion Indicator: "Your military deployment is threatening."
- Add our GUARDED bias to the GUARDED approach.
- Add our DECEPTIVE bias to the DECEPTIVE approach.

LOW
Opinion Indicator: "Your military deployment is threatening."
- Add our NEUTRAL bias to the NEUTRAL approach.

NONE
- Add our FRIENDLY bias to the FRIENDLY approach.


38. Vassalage

38A. They're a Master
If the player we're looking at has vassals:

  For each of their vassals:
  - Get our approach towards them (from the previous time it was updated), and add 1x that approach's bias to that approach's score.
  - EXCEPTION: "Special case" players are always updated before normal players, so their new approaches from this turn's update are used here.


38B. They're Someone Else's Vassal
If the player we're looking at has a master that isn't us:

  If we have the same master as them, add 2x our FRIENDLY bias to the FRIENDLY approach.

  Otherwise, for each player on their master's team:
  - Get our approach towards them (from the previous time it was updated), and add 1x that approach's bias to that approach's score.
  - EXCEPTION: "Special case" players are always updated before normal players, so their new approaches from this turn's update are used here.


38C. They're Our Master

If they're our master, then what do we think about how they've treated us?
Tip: You can view what a vassal thinks of their treatment, and why, in the Vassalage Overview.

If we are a voluntary rather than a capitulated vassal:
- Add 2x our FRIENDLY bias to the FRIENDLY approach.

If they have previously declared war on one of their own vassals:
- Add 5x our GUARDED bias to the GUARDED approach.

CONTENT
Add 5x our FRIENDLY bias to the FRIENDLY approach.
Add 2x our NEUTRAL bias to the NEUTRAL approach.
Subtract 5x our HOSTILE bias from the HOSTILE approach.
Subtract 5x our GUARDED bias from the GUARDED approach.

DISAGREE
Add 2x our FRIENDLY bias to the FRIENDLY approach.
Add 5x our NEUTRAL bias to the NEUTRAL approach.
Add 2x our HOSTILE bias to the HOSTILE approach.
Add 2x our GUARDED bias to the GUARDED approach.

MISTREATED
Add 2x our NEUTRAL bias to the NEUTRAL approach.
Add 5x our HOSTILE bias to the HOSTILE approach.
Add 5x our GUARDED bias to the GUARDED approach.

UNHAPPY
Subtract 2x our FRIENDLY bias from the FRIENDLY approach.
Subtract 2x our NEUTRAL bias from the NEUTRAL approach.
Add 5x our HOSTILE bias to the HOSTILE approach.
Add 5x our GUARDED bias to the GUARDED approach.

ENSLAVED
Subtract 5x our FRIENDLY bias from the FRIENDLY approach.
Subtract 5x our NEUTRAL bias from the NEUTRAL approach.
Add 10x our HOSTILE bias to the HOSTILE approach.
Add 10x our GUARDED bias to the GUARDED approach.


38D. Special Modifiers

We were their vassal and they refused to give us our independence when we asked:
- Add 4x our WAR bias to the WAR approach.
- Subtract 10x our DECEPTIVE bias from the DECEPTIVE approach.
- Subtract 10x our FRIENDLY bias from the FRIENDLY approach.

We were their vassal and they gave us our independence when we asked:
- Subtract 4x our WAR bias from the WAR approach.
- Add 2x our DECEPTIVE bias to the DECEPTIVE approach.
- Add 5x our FRIENDLY bias to the FRIENDLY approach.


[PART 6: STRATEGIC DIPLOMACY]


39. Social Policies

If we have similar Social Policies (visible in the Opinion table) and they're not a backstabber:
- Subtract our WAR bias from the WAR approach.
- Subtract our HOSTILE bias from the HOSTILE approach.
- Subtract our GUARDED bias from the GUARDED approach.

If we have divergent Social Policies (visible in the Opinion table):

  If their military strength compared to us is below AVERAGE:
  - Add our WAR bias to the WAR approach.
  - Add our HOSTILE bias to the HOSTILE approach.

  Otherwise:
  - Add our GUARDED bias to the GUARDED approach.


40. Religion

Skip this check if both of us don't have a majority religion yet (pantheons don't count).

The Diplo Emphasis for Religion (henceforth called "ReligionEmphasis") depends on GAME (i.e. average) era.
Ancient Era = 2
Classical Era = 4
Medieval Era = 6
Renaissance Era = 5
Industrial Era = 4
Modern Era = 3
Atomic Era = 2
Information Era = 1

If they've been converting our cities (unless they promised to stop, and kept the promise).
- Add our WAR bias plus ReligionEmphasis to the WAR approach.
- Add our HOSTILE bias plus ReligionEmphasis to the HOSTILE approach.

If we have the same religion, they're not a backstabber, and they didn't capture our Holy City:
- Add our FRIENDLY bias plus ReligionEmphasis to the FRIENDLY approach, and:
 
  If it's the World Religion and either of us is its founder or Holy City controller, then:
  - Add our FRIENDLY bias plus ReligionEmphasis to the FRIENDLY approach.

If we have different religions:
- Add our WAR bias plus ReligionEmphasis to the WAR approach.
- Add our DECEPTIVE bias plus ReligionEmphasis to the DECEPTIVE approach.
- Add our GUARDED bias plus ReligionEmphasis to the GUARDED approach.

  If their religion is also the World Religion and they're its founder or Holy City controller, then:
  - Add our WAR bias plus ReligionEmphasis to the WAR approach.
  - Add our HOSTILE bias plus ReligionEmphasis to the HOSTILE approach.
  - Add our GUARDED bias plus ReligionEmphasis to the GUARDED approach.


41. Ideology

The Diplo Emphasis for Ideology (henceforth called "IdeologyEmphasis") depends on GAME (i.e. average) era.

Industrial or earlier = 7
Modern = 9
Atomic = 10
Information = 8

If we have the same ideology and they're not a backstabber (having no ideology does not count):
- Add our FRIENDLY bias plus IdeologyEmphasis to the FRIENDLY approach.
- Subtract our WAR bias plus IdeologyEmphasis from the WAR approach.
- Subtract our HOSTILE bias plus IdeologyEmphasis from the HOSTILE approach.
- Subtract our GUARDED bias plus IdeologyEmphasis from the GUARDED approach.

If we have opposing ideologies (having no ideology does not count):
- Subtract our FRIENDLY bias plus IdeologyEmphasis from the FRIENDLY approach.
- Add our WAR bias plus IdeologyEmphasis to the WAR approach.
- Add our HOSTILE bias plus IdeologyEmphasis to the HOSTILE approach.
- Add our GUARDED bias plus IdeologyEmphasis to the GUARDED approach.


42. Global Politics - Good Alliances

Skip this check if they're a backstabber.

Loop through all other valid major civs (not on our team, not on their team, not unmet, not dead, > 0 cities).

NOTE: If we're at war with a player, we have denounced them, or they're a backstabber, then they're an enemy for the purposes of this check.

For each enemy of ours that they're at war with:
- Add 2x our NEUTRAL bias to the NEUTRAL approach.
- If we don't have opposing religions and the enemy does have a religion that opposes ours, then add ReligionEmphasis to the FRIENDLY approach.
- If we don't have opposing ideologies and the enemy does have an ideology that opposes ours, then add IdeologyEmphasis to the FRIENDLY approach.

For each enemy of ours that they've denounced:
- Add our FRIENDLY bias to the FRIENDLY approach.
- Add our NEUTRAL bias to the NEUTRAL approach.
- If we have the same religion and the enemy has an opposing religion, then add ReligionEmphasis to the FRIENDLY approach.
- If we have the same ideology and the enemy has an opposing ideology, then add IdeologyEmphasis to the FRIENDLY approach.

For each non-enemy of ours:
  If both of us have made a Declaration of Friendship with the non-enemy:
  - Add 2x our FRIENDLY bias to the FRIENDLY approach.
  - Subtract our WAR bias from the WAR approach.
  - Subtract our HOSTILE bias from the HOSTILE approach.
  - Subtract our GUARDED bias from the HOSTILE approach.
 
    If all three of us have the same religion:
   - Add ReligionEmphasis to the FRIENDLY approach.

    If all three of us have the same ideology:
   - Add IdeologyEmphasis to the FRIENDLY approach.

  If both of us have made a Defensive Pact with the non-enemy:
  - Add our FRIENDLY bias to the FRIENDLY approach.
  - Subtract our WAR bias from the WAR approach.
  - Subtract our HOSTILE bias from the HOSTILE approach.
  - Subtract our GUARDED bias from the HOSTILE approach.
 
    If all three of us have the same religion:
   - Add ReligionEmphasis to the FRIENDLY approach.

    If all three of us have the same ideology:
   - Add IdeologyEmphasis to the FRIENDLY approach.


43. Global Politics - Bad Alliances

Loop through all other valid major civs (not on our team, not on their team, not unmet, not dead, > 0 cities).

NOTE: If we're at war with a player, we have denounced them, or they're a backstabber, then they're an enemy for the purposes of this check.

For each enemy of ours:
  If this player has made a Declaration of Friendship with the enemy:
  - Add our HOSTILE bias to the HOSTILE approach.
  - Add our GUARDED bias to the GUARDED approach.
  - Subtract our FRIENDLY bias from the FRIENDLY approach.
  - Subtract 2x our NEUTRAL bias from the NEUTRAL approach.

    If they both have the same majority religion, and that religion opposes ours:
    - Add ReligionEmphasis to the WAR approach.
    - Add ReligionEmphasis to the HOSTILE approach.

    If they both have the same ideology, and that ideology opposes ours:
   - Add IdeologyEmphasis to the WAR approach.
   - Add IdeologyEmphasis to the HOSTILE approach.

  If this player has made a Defensive Pact with the enemy:
  - Add our HOSTILE bias to the HOSTILE approach.
  - Add our GUARDED bias to the GUARDED approach.
  - Subtract our FRIENDLY bias from the FRIENDLY approach.
  - Subtract 2x our NEUTRAL bias from the NEUTRAL approach.

    If they both have the same majority religion, and that religion opposes ours:
    - Add ReligionEmphasis to the WAR approach.
    - Add ReligionEmphasis to the HOSTILE approach.

    If they both have the same ideology, and that ideology opposes ours:
   - Add IdeologyEmphasis to the WAR approach.
   - Add IdeologyEmphasis to the HOSTILE approach.

For each friend (DoF Accepted) of ours:
  If this player is at war with the friend:
  - Add our WAR bias to the WAR approach.
  - Add our HOSTILE bias to the HOSTILE approach.
  - Subtract 2x our FRIENDLY bias from the FRIENDLY approach.
  - Subtract our NEUTRAL bias from the NEUTRAL approach.

    If the friend has the same majority religion as us, and this player has an opposing religion:
   - Add ReligionEmphasis to the WAR approach.
   - Add ReligionEmphasis to the HOSTILE approach.
  
   If all three of us have the same majority religion, then they're a traitor to the faith!
   - Subtract ReligionEmphasis from the FRIENDLY approach.
   - Add ReligionEmphasis to the GUARDED approach.

    If the friend has the same ideology as us, and this player has an opposing ideology:
   - Add IdeologyEmphasis to the WAR approach.
   - Add IdeologyEmphasis to the HOSTILE approach.

   If all three of us have the same ideology, then they're a traitor to the ideology!
   - Subtract IdeologyEmphasis from the FRIENDLY approach.
   - Add IdeologyEmphasis to the GUARDED approach.

  If this player has denounced the friend:
  - Add our WAR bias to the WAR approach.
  - Add our HOSTILE bias to the HOSTILE approach.
  - Subtract 2x our FRIENDLY bias from the FRIENDLY approach.
  - Subtract our NEUTRAL bias from the NEUTRAL approach.

    If the friend has the same majority religion as us, and this player has an opposing religion:
   - Add ReligionEmphasis to the WAR approach.
   - Add ReligionEmphasis to the HOSTILE approach.
  
   If all three of us have the same majority religion, then they're a traitor to the faith!
   - Subtract ReligionEmphasis from the FRIENDLY approach.
   - Add ReligionEmphasis to the GUARDED approach.

    If the friend has the same ideology as us, and this player has an opposing ideology:
   - Add IdeologyEmphasis to the WAR approach.
   - Add IdeologyEmphasis to the HOSTILE approach.

   If all three of us have the same ideology, then they're a traitor to the ideology!
   - Subtract IdeologyEmphasis from the FRIENDLY approach.
   - Add IdeologyEmphasis to the GUARDED approach.
  

44. Trade Value

- Multiply the total gold we're getting from trade routes with this player by 100.
- Multiply the total science we're getting from trade routes with this player by 100.
- Multiply the total culture we're getting from trade routes with this player by 100.

- Multiply the total gold they're getting from trade routes with us by 100.
- Multiply the total science they're getting from trade routes with us by 100.
- Multiply the total culture they're getting from trade routes with us by 100.

- Estimate our total GPT by getting the total GPT from our cities (including trade route yields) and multiply by 100.
- Estimate our total Science per turn by getting the total Science per turn from our cities (including trade route yields) and multiply by 100.
- Estimate our total Culture per turn by getting the total Culture per turn from our cities (including trade route yields) and multiply by 100.
- For the Culture estimate, also add 100x the handicap bonus (FreeCulturePerTurn) to this. The AI doesn't normally receive a Culture per turn boost but humans can add one manually via DifficultyMod.xml.

Calculate the "trade deltas" with this player:
- Gold Delta = (5 * (GPT we get - GPT they get)) / GPT estimate
- Science Delta = (5 * (SPT we get - SPT they get)) / SPT estimate
- Culture Delta = (5 * (CPT we get - CPT they get)) / CPT estimate

* The results from all divisions are rounded down to the nearest integer (any remainder is ignored).
* If any of the estimates are 0 or negative, 1 is used in place of the estimate.

Now add in the value from ongoing trade deals with this player:

[Deal Value Calculation]
Deal value starts at 0.

For each ongoing deal with them:
- If we're getting GPT from this deal, multiply the GPT by the amount of turns left in the deal, and add this to the deal value.

- If we're getting resources from this deal, multiply the number of resources in the deal by the amount of turns left in the deal, and add this to the deal value.

- If this deal allows us Open Borders in their lands, add 10 to deal value.
- If this deal allows them Open Borders in our lands, add 5 to deal value.
- If this deal has a Defensive Pact in it, add 10 to deal value.

[End Deal Value Calculation]

Now that we have the total deal value:
- Add our Diplo Balance and Loyalty leader flavors together (average for each is 5); this determines how much we care about trade loyalty.
- Multiply the total deal value by the sum of the flavors.
- Divide by 20 and discard any remainder.
- Divide by 5, discard any remainder; this is the final deal value we will use in the calculation.

Add the Gold Delta, Science Delta, Culture Delta and Trade Deal Value together.

The total is doubled if the player is considered a "strategic trade partner" (IsStrategicTradePartner function).

If the total is greater than 0:
- Add the total to the FRIENDLY approach.


45. Bankrupt

If our current Gold is 0 and our current GPT is less than or equal to 0:

If going to war with this player would actually increase our GPT (because we're paying them GPT):
- Add our WAR bias plus the amount of GPT we would gain to the WAR approach.
- Add our HOSTILE bias plus the amount of GPT we would gain to the HOSTILE approach.

Otherwise:
- Add our FRIENDLY bias to the FRIENDLY approach.
- Add our NEUTRAL bias to the NEUTRAL approach.
- Subtract our WAR bias from the WAR approach.
- Subtract our HOSTILE bias from the HOSTILE approach.


46. Bankruptcy Sanity Check

Calculate the GPT we would lose by declaring war on this player (this calculation factors in the teammates, masters, vassals, Defensive Pacts, and allied City-States we would also go to war with).

(NOTE! The GPT lost can be less than 0 - for instance, if we're giving them 50 more GPT than we're receiving in our trade deals. Also, if already at war, the calculation will always return 0.)

If the GPT we would lose is greater than 0, and one of the following conditions are true:
- This player is not close to any victory condition;
- Victory Competition was disabled in CoreChanges.sql;

Then perform the following calculation.
- Begin by calculating our current GPT income and subtracting the GPT we would lose from declaring war.
- Calculate the average of our instant Gold yields for this turn and the previous 9 turns, and add this to our GPT income.
- If the total income is negative, then calculate the amount of turns it would take for us to go bankrupt at this adjusted income rate.
- If we would go bankrupt in 30 or less turns, then the "sanity mod" is equal to the adjusted income (so if it would be -20, then the "sanity mod" is -20).
- The sanity mod is reduced by 1% for each turn it would take to go bankrupt after declaring war - if we're already bankrupt, the reduction is 0%; if it would take 30 turns, the reduction is 30%.

After this calculation:
- Subtract the sanity mod from the WAR approach.
- Subtract the sanity mod from the HOSTILE approach.


47. Current Wars

For each other player (not this player or any of their teammates) that we're at war with, analyze the war state (GetWarState function):

Our war state with this other player is CALM or a STALEMATE
- Add our NEUTRAL bias to the NEUTRAL approach.

Our war state with this other player is DEFENSIVE or we're NEARLY DEFEATED
- Add our FRIENDLY bias to the FRIENDLY approach.

If both of us are fighting together against a common foe, and it isn't because of capitulated vassalage:
- Add our FRIENDLY bias to the FRIENDLY approach.

If the player we're evaluating is a neighbor, we want him on our good side, since we're going to war with others:
- Add our FRIENDLY bias to the FRIENDLY approach.
- Add our NEUTRAL bias to the NEUTRAL approach.

If the player we're at war with is a neighbor, we want this guy on our good side, since we're going to war with neighbors:
- Add our FRIENDLY bias to the FRIENDLY approach.
- Add our NEUTRAL bias to the NEUTRAL approach.


48. Dogpiling

If this player is already at war with other major civilizations, we might want to gang up on the guy we're looking at (our potential victim).

Skip this check if we're currently losing all our wars (or nearly defeated in any war). Also skip this check if we're very unhappy.

For each other player that they're at war with, if it's a player that we've met:

If one of the following is true:
- The potential victim is a major competitor of ours;
- The other warring player's proximity to the victim is CLOSE or NEIGHBORS, and their war projection of their ongoing war against our potential victim is GOOD or better.

And the following is NOT true:
- Our war projection of ANY player at war with the victim (and CLOSE or NEIGHBORS with the victim) is STALEMATE or worse.
i.e. if we can't take someone at war with them, we don't want them to sweep over us after finishing with this guy

Then add a dogpiling bonus:
- Add weight for Victory Dispute: 0 if NONE, 1 if WEAK, 2 if STRONG, 3 if FIERCE
- Add weight for Victory Block: 0 if NONE, 1 if WEAK, 2 if STRONG, 3 if FIERCE
- Add weight for our war projection against the potential victim: 0 if DESTRUCTION, 1 if DEFEAT, 2 if STALEMATE, 3 if UNKNOWN, 4 if GOOD, 5 if VERY GOOD
- Add weight for the other warring player's war projection against the potential victim: 0 if DESTRUCTION, 1 if DEFEAT, 2 if STALEMATE, 3 if UNKNOWN, 4 if GOOD, 5 if VERY GOOD

If the total dogpiling bonus for all players at war with them is greater than 0:
- Add 1/2 the dogpiling bonus (rounded down) to the WAR approach.
- Add 1/2 the dogpiling bonus (rounded down) to the HOSTILE approach.


49. Disabled Victory Conditions

 If Science, Culture and Diplomatic Victories are all disabled:
- Add 3x our WAR bias to the WAR approach.
- Add 3x our HOSTILE bias to the HOSTILE approach.


50. They're Close to Victory

If they're close to Domination Victory:
- Add 2x our WAR bias to the WAR approach.
- Add 2x our HOSTILE bias to the HOSTILE approach.
- Add 2x our GUARDED bias to the GUARDED approach.

If they have at least one other major civ's original capital:
- Add our WAR bias plus the number of other major civs' original capitals they control to the WAR approach.
- Add our GUARDED bias plus the number of other major civs' original capitals they control to the GUARDED approach.
- Add our HOSTILE bias plus the number of other major civs' original capitals they control to the HOSTILE approach.

If victory competition has not been disabled:

   If they're close to winning a Science Victory:
   - Add 2x our WAR bias to the WAR approach.
   - Add 2x our HOSTILE bias to the HOSTILE approach.

   If they're close to winning a Culture Victory:
   - Add 2x our WAR bias to the WAR approach.
   - Add 2x our HOSTILE bias to the HOSTILE approach.

   If they're close to winning a Diplomatic Victory:
   - Add 2x our WAR bias to the WAR approach.
   - Add 2x our HOSTILE bias to the HOSTILE approach.

   If we're BOTH close to any victory condition:
   - Add 2x our WAR bias to the WAR approach.
   - Add 2x our HOSTILE bias to the HOSTILE approach.

   If they're close to any victory condition AND they're an easy target:
   - Add 5x our WAR bias to the WAR approach.


51. Grand Strategy Weight - Domination Victory

Skip this step if we're not at least in the Medieval Era (unless we're close to a Domination Victory already).

Skip this step if all of these conditions are FALSE:
- We're aiming for a Domination Victory.
- We're close to a Domination Victory.
- Our Diplo Type is CONQUEROR.


51A. Leader Flavors
Add the average of our Boldness and Offense flavors to the WAR approach.
Add the average of our Meanness and Denounce Willingness flavors to the HOSTILE approach.


51B. Capitals We Control
If we control at least one other major civ's original capital AND still control our own original capital.
- Add our WAR bias plus the number of other major civs' original capitals we control to the WAR approach.
- Add our HOSTILE bias plus the number of other major civs' original capitals we control to the HOSTILE approach.


51C. Capitals They Control
If they control at least one other major civ's original capital:

  If we're close to a Domination Victory:
  - Add 5x our WAR bias multiplied by the number of other major civs' original capitals they control to the WAR approach.
  - Add 5x our HOSTILE bias multiplied by the number of other major civs' original capitals they control to the HOSTILE approach.

  If we're not close to a Domination Victory, and they still own their original capital:
  - Add 2x the number of other major civs' original capitals they control to the WAR approach.
  - Add 2x the number of other major civs' original capitals they control to the GUARDED approach.
  - Add 2x our FRIENDLY bias MINUS 2x the number of other major civs' original capitals they control to the FRIENDLY approach.

  If they're an easy target:
  - Add 5x our WAR bias to the WAR approach.


51D. We're Close To Domination Victory
If we're close to a Domination Victory and the other player still has their original capital:
- Add 5x our WAR bias to the WAR approach.
- Add 5x our HOSTILE bias to the HOSTILE approach.

If they're also an easy target:
- Add 5x our WAR bias to the WAR approach.


51E. Normal Strategic Weight
If we're not close to a Domination Victory, and we still own our original capital:

  If the other player's military strength compared to us is above average:
  - Add our FRIENDLY bias to the FRIENDLY approach.
  - Add our NEUTRAL bias to the NEUTRAL approach.
  - Add our GUARDED bias to the GUARDED approach.
  - Subtract our WAR bias from the WAR approach.
  - Subtract our HOSTILE bias from the HOSTILE approach.
  - Subtract our DECEPTIVE bias from the DECEPTIVE approach.

  If the other player's military strength compared to us is average or weaker:
  - Subtract our FRIENDLY bias from the FRIENDLY approach.
  - Subtract our NEUTRAL bias from the NEUTRAL approach.
  - Subtract our GUARDED bias from the GUARDED approach.
  - Add our WAR bias to the WAR approach.
  - Add our HOSTILE bias to the HOSTILE approach.
  - Add our DECEPTIVE bias to the DECEPTIVE approach.

  If we have a Defensive Pact with this player, and their DP value (from DoRelationshipPairing) is greater than 0:
  - Add our FRIENDLY bias to the FRIENDLY approach.
  - Add our NEUTRAL bias to the NEUTRAL approach.
  - Subtract our GUARDED bias from the GUARDED approach.
  - Subtract our WAR bias from the WAR approach.
  - Subtract our HOSTILE bias from the HOSTILE approach.
  - Subtract our DECEPTIVE bias from the DECEPTIVE approach.

  If the other player's proximity to us is FAR or DISTANT and their economic strength compared to us is above average:
    - Add our NEUTRAL bias to the NEUTRAL approach.

    If our opinion of them is NEUTRAL or better:
    - Add our FRIENDLY bias to the FRIENDLY approach.

    Otherwise:
    - Add our DECEPTIVE bias to the DECEPTIVE approach.

    If we have a Declaration of Friendship with them:
    - Add 2x our FRIENDLY bias to the FRIENDLY approach.


51F. Open Borders
If we have no territorial disputes with them and they allow us Open Borders:
If our opinion of them is FAVORABLE or better:
- Add our FRIENDLY bias to the FRIENDLY approach.

Otherwise:
- Add our NEUTRAL bias to the NEUTRAL approach.


51G. Vassal
If they're our vassal:
- Add our FRIENDLY bias to the FRIENDLY approach.


51H. Coop Wars
If the # of times they've denied a coop war (see step 8 for how this is calculated) is above 0 (bad):
- Subtract 3x the # of denials from the FRIENDLY approach.
- Add 3x the # of denials to the HOSTILE approach.
- Add 3x the # of denials to the DECEPTIVE approach.

If the # of times they've denied a coop war is below 0 (good):
- Add 3x the # of denials to the FRIENDLY approach.
- Subtract 3x the # of denials from the HOSTILE approach.
- Subtract 3x the # of denials from the DECEPTIVE approach.



52. Grand Strategy Weight - Diplomatic Victory

Skip this step if we're not at least in the Renaissance Era (unless we're close to any victory condition already).

Skip this step if all of these conditions are FALSE:
- We're aiming for a Diplomatic Victory.
- We're close to a Diplomatic Victory.
- Our Diplo Type is DIPLOMAT.


52A. Base Friendship Increase
If the other player is not close to winning the game (or victory competition is disabled):
- Add our FRIENDLY bias plus the average of our DoF Willingness and Diplomacy flavors to the FRIENDLY approach.

   If we're also close to a Diplomatic Victory:
   - Add 2x our FRIENDLY bias to the FRIENDLY approach.


52B. Long-Term Alliances
Get the DoF Level for this player (see step 28).

DOF LEVEL: UNTRUSTWORTHY
- Add our WAR bias to the WAR approach.
- Add our GUARDED bias to the GUARDED approach.
- Add our HOSTILE bias to the HOSTILE approach.

DOF LEVEL: NEW
- Add our NEUTRAL bias to the NEUTRAL approach.

DOF LEVEL: FRIENDS
- Add our FRIENDLY bias to the FRIENDLY approach.
- Subtract our WAR bias from the WAR approach.
- Subtract our HOSTILE bias from the HOSTILE approach.

DOF LEVEL: ALLIES
- Add 2x our FRIENDLY bias to the FRIENDLY approach.
- Subtract 2x our WAR bias from the WAR approach.
- Subtract 2x our HOSTILE bias from the HOSTILE approach.
- Subtract 2x our DECEPTIVE bias from the DECEPTIVE approach.

DOF LEVEL: BATTLE BROTHERS
- Add 3x our FRIENDLY bias to the FRIENDLY approach.
- Subtract 3x our WAR bias from the WAR approach.
- Subtract 3x our HOSTILE bias from the HOSTILE approach.
- Subtract 3x our DECEPTIVE bias from the DECEPTIVE approach.


52C. City-States - Provocations
NOTE: This check is only calculated if the AI has met at least one City-State who is still alive. If there are no living City-States in the game, or they haven't met any, no bonus or penalty will be added for this.

Add the number of times they lowered our influence directly (spies, Great Diplomats, etc) to the number of times they've performed a coup against us.

(NOTE: Performing a coup also awards a penalty for lowering influence, so coups are counted twice here.)

Multiply the total by 3, and add it to the WAR and GUARDED approaches.


52D. City-States - Protection
If they haven't lowered our City-State Influence directly and our dispute level over City-States is NONE or WEAK:

For each City-State that we're protecting OR allied to, that they're protecting:
- Add 2 to the FRIENDLY approach.
- Add 2 to the NEUTRAL approach.
- Subtract 2 from the WAR approach.
- Subtract 2 from the HOSTILE approach.
- Subtract 2 from the DECEPTIVE approach.


52E. World Congress Competition
Skip this step if the World Congress has not yet been founded.
Skip this step if Victory Competition was disabled.

If this player has more World Congress votes than any other player not on our team:
- Add 2x our WAR bias to the WAR approach.
- Add 2x our HOSTILE bias to the HOSTILE approach.
- Add 2x our DECEPTIVE bias to the DECEPTIVE approach.

  If they're also an easy target:
  - Add 2x our WAR bias to the WAR approach.
  - Add 2x our HOSTILE bias to the HOSTILE approach.

  If we're also close to winning a Diplomatic Victory:
  - Add 5x our WAR bias to the WAR approach.
  - Add 5x our HOSTILE bias to the HOSTILE approach.


If this player has more votes than we do:
- Add 2x our DECEPTIVE bias to the DECEPTIVE approach.
- Add 2x our GUARDED bias to the GUARDED approach.

   If they're also an easy target:
   - Add 2x our WAR bias to the WAR approach.
   - Add 2x our HOSTILE bias to the HOSTILE approach.

   If we're also close to winning a Diplomatic Victory:
   - Add 5x our WAR bias to the WAR approach.
   - Add 5x our HOSTILE bias to the HOSTILE approach.


If this player does not have more votes than we do:
- Add 2x our FRIENDLY bias to the FRIENDLY approach.
- Subtract 2x our WAR bias from the WAR approach.
- Subtract 2x our HOSTILE bias from the HOSTILE approach.



53. Grand Strategy Weight - Cultural Victory

Skip this step if we're not at least in the Renaissance Era (unless we're close to any victory condition already).

Skip this step if all of these conditions are FALSE:
- We're aiming for a Cultural Victory.
- We're close to a Cultural Victory.
- Our Diplo Type is CULTURAL.


53A. They Have Influence Over Us
If their Influence level over us is at least POPULAR, and one of these two conditions is true:
- Their Influence over us is at least INFLUENTIAL, OR
- Their Influence trend is RISING;

Then, if victory competition is enabled:
- Add 2x our WAR bias to the WAR approach.
- Add 2x our GUARDED bias to the GUARDED approach.

  If they're also an easy target:
  - Add 2x our WAR bias to the WAR approach.
  - Add 2x our HOSTILE bias to the HOSTILE approach.


53B. Tourism Bonuses
Skip this step if any weight was added in step 53A.

If we're allowing them Open Borders:
- Add our FRIENDLY bias to the FRIENDLY approach.

   If we're also already influential on half of the civs we need in order to win a Cultural Victory:
   - Add our FRIENDLY bias to the FRIENDLY approach.

If they're our vassal:
- Add our FRIENDLY bias to the FRIENDLY approach.


53C. They're the civ we have the lowest Influence on
Skip this if we're already Influential.

If they're an easy target, and victory competition is enabled:
- Add 2x our WAR bias to the WAR approach.
- Add 2x our HOSTILE bias to the HOSTILE approach.

   If we're also close to winning a Cultural Victory:
   - Add 5x our WAR bias to the WAR approach.
   - Add 5x our HOSTILE bias to the HOSTILE approach.

If they're not an easy target:
- Add 2x our FRIENDLY bias to the FRIENDLY approach.
- Add 2x our DECEPTIVE bias to the DECEPTIVE approach.

    If we're also close to winning a Cultural Victory:
    - Add 2x our FRIENDLY bias to the FRIENDLY approach.


53D. Influence Level and Trend
Skip this step if any weight was added in step 53C.

If we're close to winning a Cultural Victory:
- Add our FRIENDLY bias to the FRIENDLY approach.

Check our influence level over them:

UNKNOWN
- Add 2x our DECEPTIVE bias to the DECEPTIVE approach.
- Add our FRIENDLY bias to the FRIENDLY approach.

EXOTIC
- Add our DECEPTIVE bias to the DECEPTIVE approach.
- Add our FRIENDLY bias to the DECEPTIVE approach.

FAMILIAR
- Add our DECEPTIVE bias to the DECEPTIVE approach.
- Add 2x our FRIENDLY bias to the FRIENDLY approach.

POPULAR
- Add 2x our FRIENDLY bias to the FRIENDLY approach.
- Add our NEUTRAL bias to the NEUTRAL approach.

INFLUENTIAL
If our Influence Trend is NOT Rising:
- Add 2x our FRIENDLY bias to the FRIENDLY approach.
- Add our NEUTRAL bias to the NEUTRAL approach.

If our Influence Trend is Rising and our Opinion of them is FAVORABLE or better:
- Add 2x our FRIENDLY bias to the FRIENDLY approach.

If our Influence Trend is Rising and our Opinion of them is COMPETITOR or worse:
- Add our WAR bias to the WAR approach.
- Add our HOSTILE bias to the HOSTILE approach.

  If they're also an easy target:
  - Add 2x our WAR bias to the WAR approach.
  - Add 2x our HOSTILE bias to the HOSTILE approach.

DOMINANT
If our Opinion of them is FAVORABLE or better:
- Add our FRIENDLY bias to the FRIENDLY approach.

If our Opinion of them is COMPETITOR or worse:
- Add 2x our WAR bias to the WAR approach.
- Add 2x our HOSTILE bias to the HOSTILE approach.

  If they're also an easy target:
  - Add 3x our WAR bias to the WAR approach.
  - Add 3x our HOSTILE bias to the HOSTILE approach.



54. Grand Strategy Weight - Spaceship Victory

Skip this step if we're not at least in the Renaissance Era (unless we're close to any victory condition already).

Skip this step if all of these conditions are FALSE:
- We're aiming for a Spaceship Victory.
- We're close to a Spaceship Victory.
- Our Diplo Type is SCIENTIFIC.


54A. Spaceship Competition
If the other player's team has built at least 1 spaceship part OR they're close to a Science Victory and we aren't:

   If victory competion is enabled:
   - Add 5x our WAR bias to the WAR approach.
   - Add 5x our HOSTILE bias to the HOSTILE approach.

If they're NOT a spaceship competitor and we're close to Science Victory:
- Add 2x our FRIENDLY bias to the FRIENDLY approach.
- Add 2x our NEUTRAL bias to the NEUTRAL approach.


54B. Normal Strategic Weight
Skip this step if any weight was added in step 54A.

They have a tech lead of 4 or more techs:
- Add our WAR bias to the WAR approach.
- Add our GUARDED bias to the GUARDED approach.
- Add our HOSTILE bias to the HOSTILE approach.

   If they're also an easy target:
   - Add our WAR bias to the WAR approach.
   - Add our HOSTILE bias to the HOSTILE approach.

They have a tech lead of 2 to 3 techs:
- Add 2x our DECEPTIVE bias to the DECEPTIVE approach.
- Add 2x our GUARDED bias to the GUARDED approach.

   If they're also an easy target:
   - Add our WAR bias to the WAR approach.
   - Add our DECEPTIVE bias to the DECEPTIVE approach.

We're equal in tech count, or within 1 tech of each other:
- Add our DECEPTIVE bias to the DECEPTIVE approach.
- Add our NEUTRAL bias to the NEUTRAL approach.

    If their military strength compared to us is at least AVERAGE:
    - Add our FRIENDLY bias to the FRIENDLY approach.

We have a tech lead of 2 to 3 techs:
- Subtract our DECEPTIVE bias from the DECEPTIVE approach.
- Subtract our GUARDED bias from the GUARDED approach.

    If their military strength compared to us is at least AVERAGE:
    - Add our FRIENDLY bias to the FRIENDLY approach.
    - Subtract our WAR bias from the WAR approach.
    - Subtract our HOSTILE bias from the HOSTILE approach.

We have a tech lead of 4 or more techs:
- Subtract 2x our DECEPTIVE bias from the DECEPTIVE approach.
- Subtract 2x our GUARDED bias from the GUARDED approach.

    If their military strength compared to us is at least AVERAGE:
    - Add 2x our FRIENDLY bias to the FRIENDLY approach.
    - Subtract 2x our WAR bias from the WAR approach.
    - Subtract 2x our HOSTILE bias from the HOSTILE approach.


54C. Defensive Pact/Research Agreement
Skip this step if any weight was added in step 54A.

If they don't have a tech lead of 4 or more techs, we have a Defensive Pact, and their DP value is above 0:
- Add 2x our FRIENDLY bias to the FRIENDLY approach.
- Add 2x our NEUTRAL bias to the NEUTRAL approach.

If they don't have a tech lead of 4 or more techs, we have a Research Agreement, and we haven't already researched every tech:
- Add 2x our FRIENDLY bias to the FRIENDLY approach.
- Add 2x our NEUTRAL bias to the NEUTRAL approach.



[PART 7: ADDITIONAL FACTORS]


55. Nukes

If the other player is a human (or Gandhi :) ), assume their chance of nuking us is 100%.

If the other player is an AI:
- If nukes have been used already by either of us against the other, assume their chance of nuking us is 100%.
- Otherwise, get the other leader's Use Nuke flavor, add 1 to it and multiply it by itself. The result is their % chance of nuking us.

We have nukes and they don't
- Add 2x our WAR bias to the WAR approach.
- Add 2x our HOSTILE bias to the HOSTILE approach.

   If they're also an easy target:
   - Add 2x our WAR bias to the WAR approach.
   - Add 2x our HOSTILE bias to the HOSTILE approach.

They have nukes and we don't, and their probability of nuking us is greater than 50%
- Add 2x our AFRAID bias to the AFRAID approach.

We both have nukes, and their probability of nuking us is greater than 25%
- Add 2x our GUARDED bias to the GUARDED approach.

If they've previously nuked us:
- Add 3x our WAR bias to the WAR approach.
- Add 3x our HOSTILE bias to the HOSTILE approach.
- Add 3x our GUARDED bias to the GUARDED approach.


56. Unique Units

If our civilization has at least one Unique Unit (UU):

If we've unlocked a UU technology and have at least one UU currently active:
- Add our WAR bias to the WAR approach.
- Add our HOSTILE bias to the HOSTILE approach.

  If we're also going for (or close to) a Domination Victory:
  - Add our WAR bias to the WAR approach.
  - Add our HOSTILE bias to the HOSTILE approach.

  If they're also an easy target:
  - Add our WAR bias to the WAR approach.

If we've unlocked a UU technology but we don't have at least one UU currently active:
- Add our DECEPTIVE bias to the DECEPTIVE approach.
- Add our WAR bias to the WAR approach.

If we don't have a UU technology, but will have one soon:
- Add our DECEPTIVE bias to the DECEPTIVE approach.


57. We're Cramped (a lot of nearby land is owned by others)

If the other player is one of our NEIGHBORS:
- Add our WAR bias to the WAR approach.
- Add our GUARDED bias to the GUARDED approach.


58. We're very unhappy AND we have more than 0 war weariness:
- Add our FRIENDLY bias plus 1/5th of our current war weariness to the FRIENDLY approach.
- Add our NEUTRAL bias plus 1/5th of our current war weariness to the NEUTRAL approach.


59. Reckless Expander

If we believe this player is a reckless expander (IsPlayerRecklessExpander function):

Opinion Indicator: "They believe we are expanding our empire too aggressively!"
- Add our WAR bias to the WAR approach.
- Add our DECEPTIVE bias to the DECEPTIVE approach.
- Add our HOSTILE bias to the HOSTILE approach.

If our diplo type is CONQUEROR:
- Add our WAR bias to the WAR approach.
- Add our HOSTILE bias to the HOSTILE approach.

If they're also an easy target:
- Add our WAR bias to the WAR approach.


60. Wonder Spammer

If we believe this player is a wonder spammer (IsPlayerWonderSpammer function):

Opinion Indicator: "They believe we are building World Wonders too aggressively!"
- Add our WAR bias to the WAR approach.
- Add our DECEPTIVE bias to the DECEPTIVE approach.
- Add our HOSTILE bias to the HOSTILE approach.

If our diplo type is CULTURAL or CONQUEROR:
- Add our WAR bias to the WAR approach.
- Add our HOSTILE bias to the HOSTILE approach.

If they're also an easy target:
- Add our WAR bias to the WAR approach.


61. Duel
If there's only two major civilizations alive:

If we're going for or close to a Domination Victory:
- Add 1000 to the WAR approach.

If victory competition is enabled:
- Add our WAR bias to the WAR approach.

  If they are also close to any victory condition and an easy target:
  - Add 1000 to the WAR approach.


62. Coop War Against This Player

If we promised another player to go to war against this player (third-party war bribery counts):
- Add our WAR bias to the WAR approach.


63. War Bonus

(This entire section is ignored for vassal players.)

War bonus starts at 0.

If our diplo type is CONQUEROR or our leader traits give us bonuses towards war:
- Add 3 to the war bonus, and also see below:

  If they're an easy target:
  - Add our WAR bias to the WAR approach.

  If our civilization has at least one Unique Unit (UU), we have the technology for a UU unlocked, AND at least one active:
  - Add our WAR bias to the WAR approach.
  - Add our HOSTILE bias to the HOSTILE approach.

  If we have a UU, a UU tech, at least one UU active, and we're going for (or are close to) a Domination Victory:
  - Add our WAR bias to the WAR approach.
  - Add our DECEPTIVE bias to the DECEPTIVE approach.

If we unlocked Authority:
- Add 1 to the war bonus.

If we completed Authority:
- Add 1 to the war bonus.

If we unlocked Imperialism:
- Add 1 to the war bonus.

If we completed Imperialism:
- Add 2 to the war bonus.

If our Ideology is Autocracy:
- Add 3 to the war bonus.

If we have a temporary attack bonus (e.g. from Global Wargames)
- Add 2 to the war bonus.


If the war bonus is greater than 0:
- Add our WAR bias plus the war bonus to the WAR approach.
- Add our HOSTILE bias plus the war bonus to the HOSTILE approach.

  If they're also an easy target:
  - Add our WAR bias to the WAR approach.


64. Difficulty Bonus

(This entire section is ignored for vassal players.)

If our Opinion of this player is COMPETITOR or worse, a bonus is also added for difficulty:

Difficulty bonus starts at 0.

- Add AIDifficultyBonusBase (see AI and Difficulty) to the difficulty bonus. This ranges from 0 (Settler) to 9 (Deity).
- If less than 0, difficulty bonus is set to 0; if greater than 10, difficulty bonus is set to 10.
- Subtract 4 if this is a COMPETITOR, 2 if this is an ENEMY, and 0 if they're UNFORGIVABLE.

If the difficulty bonus is greater than 0:
- Add our WAR bias plus the difficulty bonus to the WAR approach.
- Add our HOSTILE bias plus the difficulty bonus to the HOSTILE approach.
- Add our DECEPTIVE bias plus the difficulty bonus to the DECEPTIVE approach.

  If they're also an easy target:
  - Add our WAR bias to the WAR approach.


65. Leader Personality

(This entire section is ignored for vassal players.)

Currently only Ashurbanipal, Montezuma and Gandhi have extra weight added for this.
NOTE: The check evaluates whether the AI has the relevant traits, not the leader name.

If we are Assyria, and we haven't researched every tech already:
   If they have more techs than we do:
   - Add our WAR bias plus their tech lead to the WAR approach.

   If we have more techs than they do:
   - Add our FRIENDLY bias plus our teach lead to the FRIENDLY approach.

   If we have the same number of techs:
   - Add our NEUTRAL bias to the NEUTRAL approach.


If we are Montezuma:
- Add our WAR bias to the WAR approach.
- Add our HOSTILE bias to the HOSTILE approach.

  If the era is Medieval or earlier:
  - Add our WAR bias to the WAR approach.
  - Add our HOSTILE bias to the HOSTILE approach.


If we are Gandhi:
- Add our FRIENDLY bias to the FRIENDLY approach.

   If the other player has zero warmonger penalty with us:
   - Add our FRIENDLY bias to the FRIENDLY approach.

   If we currently have at least one nuke or have previously nuked them, and Nuclear Gandhi is enabled (DiploAIOptions.sql, active by default), then:
   - Add 100 to the WAR approach.
   - Add 100 to the HOSTILE approach.
   - Set our FRIENDLY approach score to -1000.
   - Set our NEUTRAL approach score to -1000.
   - Set our AFRAID approach score to -1000.
   - Set our DECEPTIVE approach score to -1000.


66. World Congress Resolutions

(This entire section is ignored for vassal players, or if the World Congress is disabled/hasn't been founded yet.)

If the United Nations has been constructed, and we're going for (or close to) a Diplomatic Victory:
- Add our FRIENDLY bias to the FRIENDLY approach.
- Subtract our WAR bias from the WAR approach.
- Subtract our HOSTILE bias from the HOSTILE approach.

If one of us is sanctioned by the World Congress:
- Add our WAR bias to the WAR approach.
- Add our HOSTILE bias to the HOSTILE approach.

If the Casus Belli resolution is active:
- Subtract 2x our FRIENDLY bias from the FRIENDLY approach.
- Subtract 2x our NEUTRAL bias from the NEUTRAL approach.
- Add 2x our WAR bias to the WAR approach.
- Add 2x our HOSTILE bias to the HOSTILE approach.

If the Global Peace Accords resolution is active:
- Add 2x our FRIENDLY bias to the FRIENDLY approach.
- Add 2x our NEUTRAL bias to the NEUTRAL approach.
- Subtract 2x our WAR bias from the WAR approach.
- Subtract 2x our HOSTILE bias from the HOSTILE approach.

If the Cold War resolution is active, and we can't make trade routes to at least one major civilization that we've met:

If this player has the same ideology (having no ideology doesn't count):
- Add our FRIENDLY bias plus IdeologyEmphasis to the FRIENDLY approach.
- Add our NEUTRAL bias plus IdeologyEmphasis to the NEUTRAL approach.
- Subtract our WAR bias plus IdeologyEmphasis from the WAR approach.
- Subtract our HOSTILE bias plus IdeologyEmphasis from the HOSTILE approach.
- Subtract our GUARDED bias plus IdeologyEmphasis from the GUARDED approach.

If this player has an opposing ideology (having no ideology doesn't count):
- Subtract our FRIENDLY bias plus IdeologyEmphasis from the FRIENDLY approach.
- Subtract our NEUTRAL bias plus IdeologyEmphasis from the NEUTRAL approach.
- Add our WAR bias plus IdeologyEmphasis to the WAR approach.
- Add our HOSTILE bias plus IdeologyEmphasis to the HOSTILE approach.
- Add our GUARDED bias plus IdeologyEmphasis to the GUARDED approach.


[PART 8: PRIORITIZATION]


67. Prioritization

Prioritize our approaches to avoid adopting the same approach towards too many players. This allows for more variance and strategy.

(Skip this step if there is only one player to update approaches for this turn, not counting "special case" players.)

GetBestApproachTowardsMajorCiv is called twice for each player.

On the first pass through this function, step 67 is skipped, and the final totals for each civ's approach scores are recorded at the end of this function.

If this is the second pass through this function, then for EACH of the seven approaches:
  - Collect all civilizations' first pass approach scores for this approach.
  - Rank them in order from highest approach score to lowest approach score.
  - If this civilization has the highest approach score for the approach, do not subtract any weight.
  - If this civilization is ranked second, subtract -1x the approach bias for that approach from the current score.
  - If this civilization is ranked third, subtract -2x the approach bias, and so on.
  - Ties are broken by player order (player 1 is first priority, player 2 is second priority, etc.)


68. Negative Approach Weights

At this point in the function, if any approach weight is negative, set it to 0 instead.


[PART 9: MULTIPLIERS]


69. Too Many Vassals Multiplier

If this player is not our master, and they have vassals:

- Increase the WAR approach score by 10% for each vassal they have.
- Increase the GUARDED approach score by 10% for each vassal they have.


70. Proximity Multiplier

The farther away a player is, the less likely we are to care about them!

If this player is personally able to declare war on us right now, then they CAN ATTACK US.
(They might not be able to; e.g. if a peace treaty prevents it; if the Permanent War or Peace game option is enabled.)

Check if we have a valid military attack target for this player (i.e. we can pathfind to them for an attack).
If we do have a valid attack target, then check if we WANT CONQUEST against this player.

We want conquest if any of the following conditions are true:
- We're going for Domination Victory.
- We're close to a Domination Victory.
- We promised another player to go to war against them (coop/3rd party war).
- They're a backstabber.
- Our Opinion of them is ENEMY or UNFORGIVABLE and they're our biggest competitor.
- Our Opinion of them is ENEMY or UNFORGIVABLE and they're an easy target.
- Our Opinion of them is UNFORGIVABLE and our War Projection of a war against them is GOOD or VERY GOOD.
- They're a reckless expander.
- They're a wonder spammer.
- They are close to any victory condition and victory competition is enabled.

Now, on to the proximity multiplier!

If proximity is...

NEIGHBORS
- If we want conquest, increase WAR and HOSTILE approach scores by 100%. Otherwise, if we have a valid attack target, increase them by 50%.
- If they can attack us, increase AFRAID approach score by 50%.
- Increase FRIENDLY approach score by 50%.
- Increase DECEPTIVE approach score by 50%.
- Increase GUARDED approach score by 50%.

CLOSE
- If we want conquest, increase WAR and HOSTILE approach scores by 50%. Otherwise, if we have a valid attack target, increase them by 25%.
- If they can attack us, increase AFRAID approach score by 25%.
- Increase FRIENDLY approach score by 25%.
- Increase DECEPTIVE approach score by 25%.
- Increase GUARDED approach score by 25%.

FAR
- If we want conquest and we're able to cross ocean tiles, increase WAR and HOSTILE approach scores by 25%.
- No other changes.

DISTANT
- If we don't want conquest OR we're not able to cross ocean tiles, decrease WAR and HOSTILE approach scores by 25%.
- Decrease FRIENDLY approach score by 25%.
- Decrease AFRAID approach score by 25%.
- Decrease GUARDED approach score by 25%.
- Decrease DECEPTIVE approach score by 25%.


71. Domination Victory Disabled

If Domination Victory is disabled:
- Divide the WAR approach score by 2.
- Divide the HOSTILE approach score by 2.


72. Opinion

Opinion is applied as a +/- % modifier to Approach scores after all other modifiers have been considered.

However, each leader also has several personality values which affect how much a positive or negative opinion will change their approach. These personality values are once again based on AI flavors, which are randomized slightly from game to game to be less predictable.

The higher a modifier for an approach is, the more having a positive opinion (above Favorable) or negative opinion (below Competitor) will affect that approach.

This applies both ways (a leader with a high War modifier will add more weight to the War approach if their opinion is negative, but will also remove more weight from the War approach if their opinion is positive). In contrast, a leader with a low War modifier will add or remove less weight based on opinion.

The modifiers are as follows:
WarMod = WAR bias * Boldness
HostileMod = HOSTILE bias * Denounce Willingness
DeceptiveMod = DECEPTIVE bias * Meanness
GuardedMod = GUARDED bias * (10 - Forgiveness)
AfraidMod = AFRAID bias * (10 - Boldness)
FriendlyMod = FRIENDLY bias * Loyalty
NeutralMod = NEUTRAL bias * Diplo Balance * 2

Note that in the code, good modifiers subtract opinion (negative is good) and bad modifiers add opinion (positive is bad).

IF OPINION IS GREATER THAN 30 (Competitor)

Increase hostility and fear:

- Multiply WAR approach score by (100 + WarMod + Opinion).
- Divide WAR approach score by 100.

- Multiply HOSTILE approach score by (100 + HostileMod + Opinion).
- Divide HOSTILE approach score by 100.

- Multiply DECEPTIVE approach score by (100 + DeceptiveMod + Opinion).
- Divide DECEPTIVE approach score by 100.

- Multiply GUARDED approach score by (100 + GuardedMod + Opinion).
- Divide GUARDED approach score by 100.

- Multiply AFRAID approach score by (100 + AfraidMod + Opinion).
- Divide AFRAID approach score by 100.

Decrease friendliness and neutrality:

- Multiply FRIENDLY approach score by 100.
- Divide FRIENDLY approach score by (100 + FriendlyMod + Opinion).

- Multiply NEUTRAL approach score by 100.
- Divide NEUTRAL approach score by (100 + NeutralMod + Opinion).


IF OPINION IS LOWER THAN -30 (Favorable)

- Multiply Opinion by -1.

Increase friendliness:

- Multiply FRIENDLY approach score by (100 + FriendlyMod + Opinion).
- Divide FRIENDLY approach score bv 100.

Decrease hostility, fear and neutrality:

- Multiply WAR approach score by 100.
- Divide WAR approach score by (100 + WarMod + Opinion).

- Multiply HOSTILE approach score by 100.
- Divide HOSTILE approach score by (100 + HostileMod + Opinion).

- Multiply DECEPTIVE approach score by 100.
- Divide DECEPTIVE approach score by (100 + DeceptiveMod + Opinion).

- Multiply GUARDED approach score by 100.
- Divide GUARDED approach score by (100 + GuardedMod + Opinion).

- Multiply AFRAID approach score by 100.
- Divide AFRAID approach score by (100 + AfraidMod + Opinion).

- Multiply NEUTRAL approach score by 100.
- Divide NEUTRAL approach score by (100 + NeutralMod + Opinion).


IF OPINION IS IN THE -30 TO 30 RANGE (Neutral)

Increase neutrality:
- Multiply NEUTRAL approach score by (100 + NeutralMod).
- Divide NEUTRAL approach score by 100.


73. Modder Bonus/Penalty

If base approach weight (flat or percentage) was added or subtracted in DiploApproachWeights.sql, add or subtract it now.

Flat weight is factored in before percentage weight.


[PART 10: ZERO-OUT CONDITIONS]

"Scratch value" = the approach score towards this player last turn. Used in the approach curve (part 11).
"Scratch value override" = an override for last turn's approach score. The overrides, instead of using last turn's value for the approach curve, use the specified value.

The scratch value overrides are meant to ensure that, for instance, an AI that has no valid attack target (step 75) doesn't declare war anyway because of the approach curve's slower decay.
Scratch value overrides are set to -1 by default. If set to a value of 0 or higher below, they will be used in the approach curve calculation.


74. No Valid Attack Target

If we don't have a valid attack target for this player:
- Set our WAR approach score to 0.
- Set our HOSTILE approach score to 0.
- Set the scratch value override for the WAR approach to 0.
- Set the scratch value override for the HOSTILE approach to 0.


75. Can't Attack Us

If this player can't declare war on us:
- Set our AFRAID approach score to 0.
- Set the scratch value override for the AFRAID approach to 0.


76. Recent Peace Treaty

If we signed a Peace Treaty recently, war and hostility weight is removed for a time.

On Settler difficulty, WAR, HOSTILE and DECEPTIVE weights are set to 0 for 20 turns after a peace treaty is signed.

On difficulties above Settler, the AIDifficultyBonusBase (see AI and Difficulty) is subtracted from 20 to determine how many turns the AI has no WAR/HOSTILE/DECEPTIVE weight for.
The minimum is 11 turns.

While the weights are set to 0, the WAR, HOSTILE and DECEPTIVE scratch value overrides are also set to 0.


77. Resurrection Chill-ifier

If this player resurrected us:
- Set our HOSTILE approach score to 0.
- Set our scratch value override for the HOSTILE approach to 0.


78. Coop War Soon

If we promised this player to start a coop war against another civilization "soon" and we haven't started the war yet:

If they're not close to any victory condition OR victory competition has been disabled:
- Set our WAR approach score to 0.
- Set our scratch value override for the WAR approach to 0.


79. Recent Liberation

If this player has recently liberated a city from us (within the past 20 turns), and all of the following conditions are true:
- This player is not close to any victory condition OR victory competition has been disabled.
- This player does not currently own our original capital or Holy City.
- This player is not a backstabber.

Then:
- Set our WAR approach score to 0.
- Set our scratch value override for the WAR approach to 0.


80. Vassal of Someone Else

If they're a vassal of someone else...

If we're not at war with them:
- Set our WAR approach score to 0.
- Set our scratch value override for the WAR approach to 0.

If we are at war with them, we just started the war, and our approach score towards them last turn was 0:
- Set our scratch value override to the current WAR approach score for this turn.


81. Vassal of Our Team

If they're our vassal...

If they're a major competitor of ours (this bar is set very high for vassals) or they control other major civs' original capitals, skip this next step.

If we're going for or close to a Domination Victory and they still have their original capital, skip this next step.

Otherwise:
- Set our WAR approach score to 0.
- Set our HOSTILE approach score to 0.
- Set our scratch value override for the WAR approach to 0.
- Set our scratch value override for the HOSTILE approach to 0.


82. We're Someone's Vassal

If we're someone's vassal...

If we're not at war with this player:
- Set our WAR approach score to 0.
- Set our scratch value override for the WAR approach to 0.

If we are at war with this player, we just started the war, and our approach score towards them last turn was 0:
- Set our scratch value override to the current WAR approach score for this turn.

If this player isn't our master or a backstabber, then:
- Set our HOSTILE approach score to 0.
- Set our scratch value override for the HOSTILE approach to 0.


83. Backstabbing is Bad

If we have a DoF with this player or we'd otherwise backstab a friend by going to war with them:
- Backstab a friend;
- Backstab a player we have a Defensive Pact with;
- Backstab a player we have an Opinion of ALLY towards;
- Break a military promise (not to declare war).

Then set our WAR approach score to 0 and our scratch value override for the WAR approach to 0.


84. War Disallowed By Game Options

If war against this player has been disabled in DiploAIOptions.sql:
- Set our WAR approach score to 0.
- Set our scratch value override for the WAR approach to 0.


[PART 11: THE APPROACH CURVE]


85. Make Approach Change Gradually
Approach scores change gradually from turn to turn to avoid rapid jumping between values, which would be erratic and exploitable.

For each of the approaches:

A. Retrieve the approach weight we had for this approach last turn, and store it for logging.

B. Check if there's a scratch value override for this approach with a value of 0 or higher. If so, set last turn's value to the scratch value override's value.

C. Calculate the "average" value of this turn's score and the last turn's score using this formula: (0.5 + (Approach Score * 0.10) + (Approach Score Last Turn * (1 - 0.10)))

D. Round down to remove any remainder.

E. If the average is the same as the value last turn, but the value this turn increased/decreased, then add/subtract 1 from the average so it changes by at least 1.

F. Set the approach value for this approach to the average value.

! EXCEPTION TO STEP 85: Players who have just been resurrected have outdated diplo approach values.
Therefore, the first time they update their approaches, they ignore steps 85C-E and instead use the current turn's value as last turn's value.


[PART 12: APPROACH SELECTION]


86. Select the Approach with the Highest Weight

Example: The GUARDED approach has 112 weight. The next highest approach, FRIENDLY, has 98 weight. Thus, GUARDED will be chosen.

If all approaches have 0 weight, NEUTRAL is chosen by default.

If several approaches are tied with > 0 weight, the order of priority is WAR, HOSTILE, DECEPTIVE, GUARDED, AFRAID, FRIENDLY, NEUTRAL.


87. "No Friendly" Override

If we've denounced them, they've denounced us, or they're a backstabber...

And our selected approach is FRIENDLY or DECEPTIVE, then:
- If our Opinion of them is ENEMY or UNFORGIVABLE, set our selected approach to GUARDED.
- Otherwise, set our selected approach to NEUTRAL.


88. Recent Liberation Override

If our selected approach is HOSTILE...

If this player has recently liberated a city from us (within the past 20 turns), and all of the following conditions are true:
- This player is not close to any victory condition OR victory competition has been disabled.
- This player does not currently own our original capital or Holy City.
- This player is not a backstabber.

Then set our selected approach to GUARDED.


89. War Face

If the selected approach is WAR, the AI is planning a war.

The AI will then pick a "War Face", which determines how it will act towards you until war is declared or WAR isn't the highest approach anymore.

If the selected approach is NOT the WAR approach, then it resets the War Face type (so that a new one can be decided on next time).

If the AI had a War Face last turn, it will use that one. Otherwise, it will figure out the next-highest approach score (after WAR), and based on the result, pick a war face.

If several next-highest approaches are tied, the order of priority is WAR, HOSTILE, DECEPTIVE, GUARDED, AFRAID, FRIENDLY, NEUTRAL.

If the next-highest approach score is:

HOSTILE
- AI will act HOSTILE to you until it's ready for war.

GUARDED
- AI will act GUARDED to you until it's ready for war.

DECEPTIVE
- AI will act NEUTRAL to you until it's ready for war.

AFRAID
- AI will act HOSTILE to you until it's ready for war.

FRIENDLY
- AI will act FRIENDLY to you until it's ready for war.

OTHERWISE
- AI will act NEUTRAL to you until it's ready for war.



90. War Face Overrides

If the "No Friendly" override is in place (step 87) and the selected War Face (whether or not it was changed this turn) is FRIENDLY:
- If our Opinion of them is ENEMY or UNFORGIVABLE, set our selected approach to GUARDED.
- Otherwise, set our selected War Face to NEUTRAL.

If they previously resurrected us and the currently-selected War Face is HOSTILE:
- Set our selected War Face to GUARDED.


91. Record Approach Weights

The approach weights for all seven approaches are recorded.
If this is the first pass of GetBestApproachTowardsMajorCiv for all civs, these recorded weights will be used in step 67 on the second pass.


92. Log and Update

If this is the second pass of GetBestApproachTowardsMajorCiv, then the approach has been updated, so:
- Update our approach towards this player.
- Update our War Face towards this player.
- If logging is enabled, the new approach, the approach weight, and the approach weight deltas.


93. Visible Approach

If at war, the message "WAR!" is shown in place of the approach.

If we just denounced this player, the message "DENOUNCING!" is shown in place of the approach.

If this player resurrected us this turn, the message "RECALLED TO LIFE" is shown in place of the approach.

If the true approach is DECEPTIVE, then the visible approach will be FRIENDLY.

If the true approach is WAR, then the visible approach will be the AI's War Face (step 89): HOSTILE, GUARDED, NEUTRAL or FRIENDLY.

Otherwise, the visible approach is the AI's true approach.

If the AI's visible Approach is something other than NEUTRAL, then a message explaining it can be seen in their Opinion modifiers.

---------

Special Case Approach Updates

Under specific circumstances when updating approaches towards major civs, the AI will (rather than go through the full two passes of GetBestApproachTowardsMajorCiv) use a simpler method of updating approaches to improve on performance and effectiveness.

These special case approach updates (if any) occur before the normal approach updates for the turn and are described in pseudocode below:
Code:
There are five SPECIAL CASES for approach updates:

TEAMMATES
- Have a FRIENDLY score of 9999 and a score of 0 for all other approaches.
- AI always adopts the FRIENDLY approach and NO_WAR_FACE_TYPE war face towards teammates.


PERMANENT WAR
- The "Always War" and "Permanent War or Peace" game options allow for permanent war. You can activate them with Really Advanced Setup.
- When at permanent war, AI has a WAR approach score of 9999 and a score of 0 for all other approaches.
- AI always adopts the WAR approach and NEUTRAL war face when at permanent war.


HUMAN SHADOW AI
- The human player has a shadow diplo AI. While it does not interact with other players, it still selects and updates approaches.
- Since doing a lengthy calculation would be wasteful, it uses the following simpler method.

[At War]
Approach = WAR
War Face = NEUTRAL

[Not At War]
Check if we agreed to a coop war "soon" against this player with any other player. If so, set Approach to WAR and bCoopWarAgainst to true.

If human denounced this player OR player currently owns human's original capital OR player currently owns human's Holy City:
- bCoopWarAgainst false: Set Approach to HOSTILE.
- bCoopWarAgainst true: Set War Face to HOSTILE.

If human was denounced by this player:
- bCoopWarAgainst false: Set Approach to GUARDED.
- bCoopWarAgainst true: Set War Face to GUARDED.

If human made a DoF with this player OR has a Defensive Pact with this player OR made a coop war promise "soon" to this player:
- bCoopWarAgainst false: Set Approach to FRIENDLY.
- bCoopWarAgainst true: Set War Face to FRIENDLY.

If none of these are true:
- bCoopWarAgainst false: Set Approach to NEUTRAL.
- bCoopWarAgainst true: Set War Face to NEUTRAL.

Set the selected approach's score to 5 and all other approach scores to 0.



AI HAS NO CAPITAL
- If the AI has no capital city (possible at game start or with the Complete Kills game option), then it selects and updates approaches towards all other players quickly.

[At War]
Approach = WAR
War Face = NEUTRAL

[Not At War]
Check if we agreed to a coop war "soon" against this player with any other player. If so, set Approach to WAR and bCoopWarAgainst to true.

If AI denounced this player OR player currently owns AI's original capital OR player currently owns AI's Holy City OR AI considers player a backstabber:
- bCoopWarAgainst false: Set Approach to HOSTILE.
- bCoopWarAgainst true: Set War Face to HOSTILE.

If AI was denounced by this player:
- bCoopWarAgainst false: Set Approach to GUARDED.
- bCoopWarAgainst true: Set War Face to GUARDED.

If AI made a DoF with this player OR has a Defensive Pact with this player OR made a coop war promise "soon" to this player OR was previously resurrected by this player:
- bCoopWarAgainst false: Set Approach to FRIENDLY.
- bCoopWarAgainst true: Set War Face to FRIENDLY.

If player has previously captured some of the AI's cities:
- bCoopWarAgainst false: Set Approach to GUARDED.
- bCoopWarAgainst true: Set War Face to GUARDED.

If none of these are true:
- bCoopWarAgainst false: Set Approach to NEUTRAL.
- bCoopWarAgainst true: Set War Face to NEUTRAL.

Set the selected approach's score to that approach's bias value and all other approach scores to 0.



TARGET PLAYER HAS NO CAPITAL
- Towards players that have no cities, a lengthy approach update is a waste of time, and may return erroneous results (e.g. due to their lack of military/economic strength).
- Players with no cities are disregarded for most diplomacy AI purposes, but approaches towards them will still be selected using this simple method.

[At War]
Approach = WAR
War Face = NEUTRAL

[Not At War]
Check if we agreed to a coop war "soon" against this player with any other player. If so, set Approach to WAR and bCoopWarAgainst to true.

If AI denounced this player OR AI considers player a backstabber:
- bCoopWarAgainst false: Set Approach to HOSTILE.
- bCoopWarAgainst true: Set War Face to HOSTILE.

If AI was denounced by this player:
- bCoopWarAgainst false: Set Approach to GUARDED.
- bCoopWarAgainst true: Set War Face to GUARDED.

If AI made a DoF with this player OR has a Defensive Pact with this player OR made a coop war promise "soon" to this player OR was previously resurrected by this player:
- bCoopWarAgainst false: Set Approach to FRIENDLY.
- bCoopWarAgainst true: Set War Face to FRIENDLY.

If none of these are true:
- bCoopWarAgainst false: Set Approach to NEUTRAL.
- bCoopWarAgainst true: Set War Face to NEUTRAL.

Set the selected approach's score to that approach's bias value and all other approach scores to 0.
 
Last edited:
This looks great! Can't wait to try it out.

I "accidentally" betrayed Austria who was aggressively forward settling, but had to quit the game in late medieval due to diplo penalties, and I wondered, how long do backstabbing penalties last? 100 turns? I feel they should last only for a duration of a trade deal.
 
An absolute incredible summary, simply amazing.

I read through it all, though it is a hell of a lot to take in. My first impression, it seems to me that there are a large number of things that add x2, x3, x4, etc biases to war and hostility. The things that do the same for friendly status are things you normally need friendly status for (aka DOFs).

I knew the deck was stacked in favor of hostility, but looking at it, I don't see a lot of levers to pull to incur friendship with another player other than going to war when they ask, always accepting a DOF, and trading with them a lot. But even those are pretty weak in comparison to so many options that will go x2, x3, x4 war bias.
 
I was lost after the first 100 lines... Hope you make some sense of it.

My only insight is that competition could be tricky. Usually there's a runaway who's just good at everything, so it's hard to not hate that guy.
A different way to see competition, is to label each player upon the relative commitment to a victory condition. If I see a player that has more votes than the average, but not more techs or tourism or capitals than the average, then I'd label that player as a diplomatic one, and I'll make the strongest among the diplomatic players my enemy if I'm interested in diplomacy too. It doesn't need to be the player with more votes. Maybe the player with more votes has also the lead in capitals and can be labeled as a domination player, more than a diplomatic one. So I don't have reasons to fight him before entering the panic mode.

In short, I don't hate people pursuing different victory types, even if they are still better than me in my desired victory condition. But I might hate people trying to get my victory condition, even if they are currently weaker than me.
It's a matter of comparing every player relative strength in every area. For example, if my tourism output is much more over the average than my number of votes, army might and tech lead, then I'm clearly aiming for cultural victory and I deserve cultural civs hatred. How focused I am in my victory condition is what could increase the hatred of the other cultural civs.
 
This is great! I read that friends and allies do not try to block your victory, is that new? I really like this, much more immersive and rewarding for building relationships. It of course advantages the human player who might turn on its bestie at the end, but is compensated by friendships being harder to build on higher difficulties. This is a very nice balance between immersion and human advantage.

I was lost after the first 100 lines... Hope you make some sense of it.

My only insight is that competition could be tricky. Usually there's a runaway who's just good at everything, so it's hard to not hate that guy.
A different way to see competition, is to label each player upon the relative commitment to a victory condition. If I see a player that has more votes than the average, but not more techs or tourism or capitals than the average, then I'd label that player as a diplomatic one, and I'll make the strongest among the diplomatic players my enemy if I'm interested in diplomacy too. It doesn't need to be the player with more votes. Maybe the player with more votes has also the lead in capitals and can be labeled as a domination player, more than a diplomatic one. So I don't have reasons to fight him before entering the panic mode.

In short, I don't hate people pursuing different victory types, even if they are still better than me in my desired victory condition. But I might hate people trying to get my victory condition, even if they are currently weaker than me.
It's a matter of comparing every player relative strength in every area. For example, if my tourism output is much more over the average than my number of votes, army might and tech lead, then I'm clearly aiming for cultural victory and I deserve cultural civs hatred. How focused I am in my victory condition is what could increase the hatred of the other cultural civs.

but why not hating the runaway? S/he will be much harder to stop later because of its overall power (all types of lead benefit the other victories to some degree), and will have an easier time switching victory type if one is blocked. As a human I'm quite concerned by any runaway even if not a direct competitor, it seems fair such civ would be hated earlier no? Wouldn't your approach penalize too much weaker civs and help too much stronger ones? Besides, generalist runaways already have an advantage by being more intimidating to attack, because of the game's intrinsic limits to military coalitions (maybe 3-4 civs would be willing to go to war together against the leader, but they can't know beforehand if the others are in so they don't and prey on weaker ones).

It also leads to another question, should overall strength (score) be factored as a a runaway diplo penalty?
 
It is my understanding that the AI enters panic mode whenever a player threatens with victory. Furthermore, they are opportunistic and will still attack you for being weak. So AI plays for winning anyway.
This will address a common complaint about all AI ganging on the human player and making it impossible to keep friends. It's not fun to lose all your friends in Renaissance just because you are doing it better than them, because you are playing at an easier difficulty than you can play. And fun should come first.

About being too late to stop a runaway, chances are that the runaway will have some haters, close neighbors or civs going for the same victory. These haters could try to form alliances against their enemies, since they are on the weak side.
If that fails, then the sensitivity for the panic mode could be increased.

I think it will produce a richer experience to have enemies based on your kind of play, rather than on your success, since it's becoming too predictable that being prominent is a recipe for being gang banged.

Edit. Now that I think about it, maybe there are other natural enemies. Maybe diplomatic civs hate warmongers, warmongers hate cultural civs, cultural hate scientific and scientific hate diplomatic. That will spice things a little more.
 
Last edited:
Another thing.
Is it OK that there's a penalty for divergent social policies?
I understand that divergent ideologies brings bad will. We can pursue different victory conditions with the same ideology.

But it feels weird to complain about not picking a Statecraft, and then complain about competing for the same city states. The same thing happens to Tradition and wonder hoarding. If you take Tradition, of course you want to build wonders. Then, why do you hate all civs that did not take Tradition? Unlike other Tradition players, they won't build many wonders.

If ever, the penalty should be for sharing the same policies. People sharing the same policies are more likely to compete for the same things.
 
Apologies for a lack of response to this, the pandemic has been keeping my life busy. But I appreciate the feedback!

This looks great! Can't wait to try it out.

I "accidentally" betrayed Austria who was aggressively forward settling, but had to quit the game in late medieval due to diplo penalties, and I wondered, how long do backstabbing penalties last? 100 turns? I feel they should last only for a duration of a trade deal.

Breaking a DoF = 75 turns, scaling
Denouncing a friend = 100 turns, scaling
Declaring war on a friend/vassal = 150 turns, scaling

Perhaps a reduction to 50/75/125? It is long, but betraying your friends results in heavy diplomatic penalties for good reason.

An absolute incredible summary, simply amazing.

I read through it all, though it is a hell of a lot to take in. My first impression, it seems to me that there are a large number of things that add x2, x3, x4, etc biases to war and hostility. The things that do the same for friendly status are things you normally need friendly status for (aka DOFs).

I knew the deck was stacked in favor of hostility, but looking at it, I don't see a lot of levers to pull to incur friendship with another player other than going to war when they ask, always accepting a DOF, and trading with them a lot. But even those are pretty weak in comparison to so many options that will go x2, x3, x4 war bias.

Glad you liked it.

Diplomacy is as much (if not more) about avoiding hostility as it is making friends. If it were easy to make friends the AI would be exploitable.

But keep in mind that while there are many ways to make the AI hostile, it is highly unlikely for all of them to be active simultaneously, and many of them (particularly the Provocations section and being an easy target) are controllable. The major bugfix to military strength estimates for next version should help with this.

Remember also that the AI ranks civs in order of priority; the farther you are from the highest priority WAR civ, the less likely you are to be DoW'ed. And this effect has been increased (with some nuance) for ongoing wars in the next version.

Also, friendship willingness is controlled by separate functions than the approach calculation.

In any case, I've made modifications to this logic for the next (full!) version. I'll post the new approach calculation when the new version is released; looking forward to everyone's feedback! :)

I was lost after the first 100 lines... Hope you make some sense of it.

My only insight is that competition could be tricky. Usually there's a runaway who's just good at everything, so it's hard to not hate that guy.
A different way to see competition, is to label each player upon the relative commitment to a victory condition. If I see a player that has more votes than the average, but not more techs or tourism or capitals than the average, then I'd label that player as a diplomatic one, and I'll make the strongest among the diplomatic players my enemy if I'm interested in diplomacy too. It doesn't need to be the player with more votes. Maybe the player with more votes has also the lead in capitals and can be labeled as a domination player, more than a diplomatic one. So I don't have reasons to fight him before entering the panic mode.

In short, I don't hate people pursuing different victory types, even if they are still better than me in my desired victory condition. But I might hate people trying to get my victory condition, even if they are currently weaker than me.
It's a matter of comparing every player relative strength in every area. For example, if my tourism output is much more over the average than my number of votes, army might and tech lead, then I'm clearly aiming for cultural victory and I deserve cultural civs hatred. How focused I am in my victory condition is what could increase the hatred of the other cultural civs.

The existing competition checks attempt to do this; a cultural civ will care more about wonder disputes, a warmonger will care more about territorial disputes, etc. And the victory condition they're going for is factored into this significantly.

Furthermore, the only competition checks that are direct penalties for success are the tech competition penalty (which is only major for scientific civs) and the victory dispute/block penalties, which are based on the AI's Victory Competitiveness flavor and the era. Other checks are penalties for directly competing with the era on some level (building Wonders they want, stealing their City-State allies).

These have also been tweaked for next version (to reduce some excess friendliness and hostility).

This is great! I read that friends and allies do not try to block your victory, is that new? I really like this, much more immersive and rewarding for building relationships. It of course advantages the human player who might turn on its bestie at the end, but is compensated by friendships being harder to build on higher difficulties. This is a very nice balance between immersion and human advantage.

but why not hating the runaway? S/he will be much harder to stop later because of its overall power (all types of lead benefit the other victories to some degree), and will have an easier time switching victory type if one is blocked. As a human I'm quite concerned by any runaway even if not a direct competitor, it seems fair such civ would be hated earlier no? Wouldn't your approach penalize too much weaker civs and help too much stronger ones? Besides, generalist runaways already have an advantage by being more intimidating to attack, because of the game's intrinsic limits to military coalitions (maybe 3-4 civs would be willing to go to war together against the leader, but they can't know beforehand if the others are in so they don't and prey on weaker ones).

It also leads to another question, should overall strength (score) be factored as a a runaway diplo penalty?

Victory Block penalties not applying to Friends has been the case for a few months now. Seems it's been more fun that way, and it's not necessarily bad strategy for the AI, either.

Overall score being factored in would be double dipping on the existing penalties. I think it'd be unnecessary.

It is my understanding that the AI enters panic mode whenever a player threatens with victory. Furthermore, they are opportunistic and will still attack you for being weak. So AI plays for winning anyway.
This will address a common complaint about all AI ganging on the human player and making it impossible to keep friends. It's not fun to lose all your friends in Renaissance just because you are doing it better than them, because you are playing at an easier difficulty than you can play. And fun should come first.

About being too late to stop a runaway, chances are that the runaway will have some haters, close neighbors or civs going for the same victory. These haters could try to form alliances against their enemies, since they are on the weak side.
If that fails, then the sensitivity for the panic mode could be increased.

I think it will produce a richer experience to have enemies based on your kind of play, rather than on your success, since it's becoming too predictable that being prominent is a recipe for being gang banged.

Edit. Now that I think about it, maybe there are other natural enemies. Maybe diplomatic civs hate warmongers, warmongers hate cultural civs, cultural hate scientific and scientific hate diplomatic. That will spice things a little more.

AI already tries to form alliances with their enemies' enemies.

The panic mode only takes place late in the game (Modern to Information Eras), not in the Renaissance. I believe some of the Renaissance aggression issues should be resolved for next version.

Another thing.
Is it OK that there's a penalty for divergent social policies?
I understand that divergent ideologies brings bad will. We can pursue different victory conditions with the same ideology.

But it feels weird to complain about not picking a Statecraft, and then complain about competing for the same city states. The same thing happens to Tradition and wonder hoarding. If you take Tradition, of course you want to build wonders. Then, why do you hate all civs that did not take Tradition? Unlike other Tradition players, they won't build many wonders.

If ever, the penalty should be for sharing the same policies. People sharing the same policies are more likely to compete for the same things.

The idea here is 1) immersion; different government types historically got along worse than similar ones; 2) that civs with divergent Social Policies will be better able to exploit each other's weaknesses. Authority civs have more military power than Tradition civs, Tradition civs will tend to be superior in science and culture, etc.
 
AIs should be reacting more preventively and earlier in regards to runaway civs (player included). Both in terms of civ size/score as well as tech since that's extremely indicative of winning for all victory types. If a civ is just walking away with the game, the rest should be reacting proactively from at least the renaissance era. Leaving it until the modern era is just giving the AIs enough rope to hang themselves once the snowball has gotten too far to be stopped. AIs should be fine with lesser differences in power/score/science, but should get extremely aggressive towards anyone really sticking their head above the pack to the point of being totally dominant.

This will make the game a lot harder for the player typically (unless going diplo/culture which should only bring penalties with civs following similar approaches), but also prevent "impossible scenarios" on higher difficulty levels where someone just walks away from it after the medieval.

My last game, Askia ended up with almost 40% of the map under his control, and it seemed like nobody cared to coordinate to stop him, he just went from one weaker neighbor to the next, conquering them in turn until I showed up with my nukes in the late game. He had aggressive neighbors, too, and they mostly stood on the sidelines. I can't imagine a human player ever allowing that (I was opposite side of map and dealing with my own neighbors) for good reason.

I do like having some AI snowballing effect, but it's probably better to have things balanced against snowballs both for other AIs and the human.

The AIs should always be looking for balance in international affairs. Power blocs should be the primary focus on AI diplomacy rather than trading partners and lesser grievances.

If a neighbor is grabbing territory, an AI should either be looking to coalition against them or grab territory of their own to form a balance again with the expanding neighbor. Being friendly for other reasons and not getting aggro is just a recipe for eventually being conquered/vassalized.

I mentioned in another thread about having instant warmonger penalties based on expectations of war outcome rather than having the warmong penalties be reactively scaling with combat. However you do it, expectations and power imbalances need to be more front and center in AI calculations.
 
Last edited:
AIs should be reacting more preventively and earlier in regards to runaway civs (player included). Both in terms of civ size/score as well as tech since that's extremely indicative of winning for all victory types. If a civ is just walking away with the game, the rest should be reacting proactively from at least the renaissance era. Leaving it until the modern era is just giving the AIs enough rope to hang themselves once the snowball has gotten too far to be stopped. AIs should be fine with lesser differences in power/score/science, but should get extremely aggressive towards anyone really sticking their head above the pack to the point of being totally dominant.

This will make the game a lot harder for the player typically (unless going diplo/culture which should only bring penalties with civs following similar approaches), but also prevent "impossible scenarios" on higher difficulty levels where someone just walks away from it after the medieval.

My last game, Askia ended up with almost 40% of the map under his control, and it seemed like nobody cared to coordinate to stop him, he just went from one weaker neighbor to the next, conquering them in turn until I showed up with my nukes in the late game. He had aggressive neighbors, too, and they mostly stood on the sidelines. I can't imagine a human player ever allowing that (I was opposite side of map and dealing with my own neighbors) for good reason.

I do like having some AI snowballing effect, but it's probably better to have things balanced against snowballs both for other AIs and the human.

The AIs should always be looking for balance in international affairs. Power blocs should be the primary focus on AI diplomacy rather than trading partners and lesser grievances.

If a neighbor is grabbing territory, an AI should either be looking to coalition against them or grab territory of their own to form a balance again with the expanding neighbor. Being friendly for other reasons and not getting aggro is just a recipe for eventually being conquered/vassalized.

I mentioned in another thread about having instant warmonger penalties based on expectations of war outcome rather than having the warmong penalties be reactively scaling with combat. However you do it, expectations and power imbalances need to be more front and center in AI calculations.

Well, that's some good performance on Askia's part. :)

I've made some big modifications to this logic for the upcoming version (specifically, you should find the AI far more aggressive and responsive in the early game, and significantly more hostile towards conquerors who pose a threat to them overall). Let me know what you think!
 
Yeah, I was very happy with Askia's snowball there. I hadn't seen that sort of performance in vanilla really. The new changes are already very nice, but of course I gotta make suggestions :)

To add, the AIs that seem to be doing best in my games are:

Askia, Sejong (of course), Poland (doesn't expand much but handles econ well), and Mongolia (opposite). Not enough to be statistically accurate, but they seem to have a highly competent mix of flavors.

Edit for 4-17DLL: yes, this is better. The AI is at least trying to check my expansion, though I haven't seen any other AIs engage very aggressively or expand into their neighbors. I might be taking the spotlight.
 
Last edited:
Critical feedback from first game (prince, aptly titled Stalingrad, 12civ/0CS/normal/oval):

The AI did an exceptional (and ultimately successful) job of keeping me in check. Somewhat obnoxiously, because every war I fought was fairly essential to establish myself and kneecap snowballers like Sejong and Askia. I felt fairly cornered the entire game, which is nice if not a bit frustrating. A fun loss. Vanilla civ, I was fairly competent at Emperor-Immortal level, and I'm finding Prince to be a crapshoot. That's good, this mod is certainly stretching my skills, some of which is part of being in the learning curve still, but mostly the AI is just a lot better and more responsive now.

Warmonger penalties... mostly seemed to be built up against people I actually fought, except Siam had them off the charts for some reason. Other civs that should have had them higher didn't have them at all. Maria was next to me, and I fought countless neighbor wars, often aggressive, and she just sat there smiling. I get that she likes to build away in peace, but even the Builders need to step in when they're next to a me/Askia/Khan. I fought literally every neighbor except her at some point (and all at once in the end) and didn't have a single -1 warmonger from her (and a lot of civs).

Wonder penalties are broken, or maybe I broke it with IGE. I have 3/27 wonders, somewhere around the median, versus Morocco with 10, and I'm getting -20 and -40 diplo with half the civs for some reason. That does not make any sense. However, I did have to use IGE to destroy and rebuild Seoul due to a tile yield bug, which had 4 wonders, so maybe the underlying mechanics included those, though my total "wonders" on the InfoAddict rankings was indeed 3. Still, if it's 7 wonders when Morocco has 10... ehhhh, a mild penalty of like -10 is more fitting than -40. -40 is a huge hit.

Citadel bombing penalties are pretty messed up. The AI constantly citadel bombs, but then I get a -30 per just to retake the tiles they literally just took from me? At the very least, it should be a "NET citadel bomb" rather than absolute. If they take 4 tiles and I take 4 tiles back, it should be a wash. If I take 2 tiles when they haven't taken any, then yeah like -20 is fair. At this point I just want to delete the GG and IGE the tiles to avoid it.

Relations overview for me:


Spoiler :
Alexander: War-12, Behavior-19
Askia: War-17, Territory-35, Wonders-40 (I just finished a war with them and took some territory with HR&C)
Ahmad: Civs-14, Territory-25, War-34, StoleTerritory-60 (ffs they citadel bombed me twice first)
Pacal: War-6, Tech-10
Pocatello: War-20, Territory-35, Wonders-40
Siam: Plunder-5, Social-5, War-59
Sejong: Tech-20, Wonders-20, Territory-25, War-48, CapCap-160
Germany: 0
Maria: Wonders-20, Territory-40
Caesar: War-21


History:
Spoiler :
T83 Egypt DoW Pocatello (expansion?)
T100 me DoW Pocatello (breathing room)
T104 raze his city, cap some territory
T111 Peace out
T111 Askia DoW Poc (opportunistic dogpile?)
T135 Askia peace Poc
T136 me DoW Sejong
T144 me cap Seoul
T146 me peace out Sejong
T154 Bismark DoW me (super friendly, wtf moment)
T155 Pocatello DoW me (makes total sense)
T155 Askia DoW Egypt (expansion)
T157 Siam DoW me (also a bit wtf? though his warmonger -pen was huge)
T158 Ahmad DoW me (makes sense as my neighbor)
T176 Ahmad peace out me
T177 Bismark peace out me
T180 Siam peace out me (never saw him)
T185 Askia cap 1 city Egypt
T188 Pocatello peace out me
T198 Askia cap cap Egypt - Egypt ded (the snowball is getting real here)
T203 Askia DoW Alexander (expansion)
T211 Pocatello DoW me (angry much?)
T214 Pocatello DP Bismark
T215 Siam DP Maria
T215 Bismark DP Siam
T216 Poctallo DP Ahmad
T217 Alex DP Siam
T217 Poc DP Siam
T217 Siam DP Ahmad
T217 Bismark DP Ahmad
T220 Pacal DP Maria
T220 Sejong DP Alex
T220 Bismark DP Alex
T220 Maria DP Alex
T222 Caesar DP Askia (and I can't get a single one...)
T222 Askia DoW Bismark/Maria/Pacal (ummm.... I feel like some of the DPs did not function here?)
T224 Sejong DP Maria
T226 Me peace Poc
T230 Askia peace Alex
T233 me DoW Askia/Caesar
T237 Caesar DP Alex
T240 Poc DP Bismark & Caesar
T241 Sejong DoW me (sensible for sure)
T244 me cap 1 city Askia
T244 Askia recap
T248 Caesar peace me (never saw him either)
T250 Bismark peace Askia
T252 Ahmad DoW me (opportunistic, and successful I didn't have much to defend our border, all was on the Askia frontlines)
T252 Pacal peace Askia
T252 Maria peace Askia
T253 Poc DoW me (also very sensible vs undefended area)
T256 ah f- this

Discussion:

Oddities: T154-157 Bismark/Poc/Siam DoWs on me after I'd peaced Sejong, where the only one of the 3 that could reach me was horribly underpowered vs me, and after I'd already cleaned the floor with him earlier, plus having almost a full era on him in tech and like double the military score. This would have made sense before the Sejong peace, but not after, even 2 turns after. Having 2 people on the opposite side of the map DoW me for no apparent reason other than presumably disliking my capturing of a capital... then contributing nothing to the fight, makes little sense, especially when one was super friendly at that point.

By T200, Askia was growing unstoppable, and it's not clear if the other AIs reacted properly to check him. I would've liked to see how that progressed later into the game, but alas Stalingrad was a defeat for Russia this time around. I had to spread too thin to take on Askia and the Seoul dogpile, but had little choice but to give it everything to kneecap Askia before he became unstoppable. It looked like Siam was building up to attack him near the end, so perhaps I jumped the gun there. I just saw him at war with 4 civs and ran in. Clearly, it was still a very uphill battle, probably I was the only one in his territory.

Askia's DoW of Bismark/Maria/Pacal on T222 makes very little sense (not sure who the primary target was there on the log, likely Bismark) when he's already in a stalemate with Alex. That should have been the other way around (I thought it was actually, but the log clearly states an Askia DoW).

I noted very little expansion in this game. Up until T154 I was the only aggressor. Note that I play a very crammed map, so by T100 everyone has filled out borders with 3-4 cities at most. Other than Askia and myself, nobody went for aggressive expansion it seems. The Maya, Rome, and Alex should've been on top of that.
 
Last edited:
Citadel bombing penalties are pretty messed up. The AI constantly citadel bombs, but then I get a -30 per just to retake the tiles they literally just took from me? At the very least, it should be a "NET citadel bomb" rather than absolute. If they take 4 tiles and I take 4 tiles back, it should be a wash. If I take 2 tiles when they haven't taken any, then yeah like -20 is fair. At this point I just want to delete the GG and IGE the tiles to avoid it.
These aren't global penalties, are they? Generational animosity on both sides from fighting over land seems fine to me.
 
These aren't global penalties, are they? Generational animosity on both sides from fighting over land seems fine to me.

They're local. Accumulated only during peacetime, and cleared when you go to war.

@MontyJava Thank you for the detailed feedback, I'll respond later today.
 
One little off-topicish addition: regarding trades, it seems super easy to exploit strat resource trades with the AI. I've noticed AIs with 10+ iron will still buy yours up and pay sometimes ridiculous like 3-5GPT per iron when they clearly don't need any for the next 30 turns. I've done my best to stop exploiting this, but it's hard to know what's actually appropriate and what's cheese.
 
One little off-topicish addition: regarding trades, it seems super easy to exploit strat resource trades with the AI. I've noticed AIs with 10+ iron will still buy yours up and pay sometimes ridiculous like 3-5GPT per iron when they clearly don't need any for the next 30 turns. I've done my best to stop exploiting this, but it's hard to know what's actually appropriate and what's cheese.

Sometimes they do and sometimes they don't. In most cases it does seem that people with lots of strategic resources (e.g. Russia) won't pay you for more and those with none will pay lots. I do think it's probably overtuned at the moment but I think there is also reason to the rhyme overall. I also haven't much tried the latest beta yet so I'm curious to see what that is like.
 
One little off-topicish addition: regarding trades, it seems super easy to exploit strat resource trades with the AI. I've noticed AIs with 10+ iron will still buy yours up and pay sometimes ridiculous like 3-5GPT per iron when they clearly don't need any for the next 30 turns. I've done my best to stop exploiting this, but it's hard to know what's actually appropriate and what's cheese.

AI will ask to buy coal, as soon as I had it, even though I was the tech leader, and the AI was still half an era from even seeing coal themselves, let alone being able to use it in any capacity. Very silly. They really need to only buy stuff that they have need for.
 
A T300 review of new game. I've aimed for a bit more brevity, and I've divided things up into clear wars. You can ignore the spoiler unless you want more details.

Spoiler :
T088 - City founding mostly over

T084 - Dido DoW Gust - (Neighbors, Dido +50% mil, buildup)
T107 - Dido Pea Gust

T092 - Huns DoW Port - (Neighbors, +40%, mild buildup)
T098 - Inca DoW Port - (Neighbors, mil score ==, dogpile?)
T119 - Huns cap 1 city Port
T121 - Inca Pea Port
T128 - Huns Pea Port

T116 - Gust DoW Hiaw - (Neighbors, Gust has 5% lower mil score, Hiaw buildup not Gust???)
T130 - Dido DoW Gust - (again, neighbors, 10% higher mil)
T134 - Huns DoW Hiaw - (now neighbors, 5% lower mil)
T139 - Hiaw Pea Gust
T152 - Dido Pea Gust
T158 - Huns Pea Hiaw

T157 - Huns DoW Port - (now neighbors, Huns +80% mil)
T179 - Huns Pea Port

T189 - Gust DoW Hiaw - (again, neighbors, == mil, no buildup)
T191 - Huns DoW Hiaw - (again, neighbors, dogpile)
T210 - Hiaw Pea Gust
T215 - Huns Pea Hiaw

T201 - Plyr DoW Port - (she had it coming, citadel bombs and all)
T204 - Huns DoW Port - (again, dogpile, neighbors)
T211 - Plyr cap cap Port
T211 - Port recap cap - (ships capturing cities is about my least favorite aspect of this game)
T212 - Plyr cap cap Port
T213 - Plyr Pea Port
T226 - Huns cap 1 city Port
T240 - Huns VAS Port

T217 - Dido DoW Isab - (Not neighbors, Dido +40%, mild buildup)
T232 - Dido Pea Isab

T230 - Gust DoW Baby / Dido / Lizy
T251 - Dido Pea Gust
T252 - Baby Pea Gust

T238 - Huns DoW Gust / Inca / Isab
T250 - Huns Pea Gust
T253 - Huns Pea Isab
T259 - Inca Pea Huns

T243 - Dido Dow Inca / Isab / Sejo / Poca (Poca gets hit. Are neighbors both, +35% mil, huge buildup)
T255 - Sejo Pea Dido
T258 - Dido Pea Isab
T266 - Inca Pea Dido
T266 - Dido cap cap Poca
T270 - Dido cap 1 city Poca
T275 - Dido cap 1 city Poca - (Poca ded)

T244 - Lizy DoW Inca / Isab / Gust (Isab target, are neighbors)
T256 - Lizy Pea Inca
T266 - Isab Pea Lizy
T268 - Lizy DoW Inca / Baby / Hiaw / Sejo / Poca

T272 - Lizy DoW Plyr - (like she didn't have enough on her plate???)
T272 - Huns DoW Plyr - (neighbors, legit though no actual invasion, mad buildup but mil==, very weak assault)
T275 - My first DP in this mod, wow, with Inca!
T276 - Dido DoW Inca / Plyr - (going after me I guess)
T278 - Plyr cap 1 city Huns for 1 turn
T284 - Inca Pea Lizy
T285 - Plyr knocks out Port, raze city and all its god-forsaken citadels
T288 - Lizy Pea Plyr
T290 - Sejo DoW Inca / Plyr - (I am target, never actually invades me or does anything)
T291 - Sejo cap 1 city Lizy - (and that's why, army is on other side of territory)
T294 - Plyr cap 1 city Huns - (for keepsies this time)
T294 - Dido Pea Plyr
T297 - Inca Pea Dido
T297 - Plyr pea Dido / Huns
T297 - Hiaw pea Lizy
T298 - Baby Pea Lizy
T299 - Plyr cap 1 city Sejo
T299 - Sejo Pea Lizzy


Discussion:

The T084 Dido-Gust war was sensible. She apparently did very well but never captured a city.

The Huns' T92 war against Portugal was likewise smart, as was the Inca dogpile, and far more successful for the Huns, which took a very nice city (a spot I was planning to settle as a priority).

Then the warmaking got ridiculous. The T116 Gustavus war against Hiawatha was nonsensical. He had a LOWER military score (I was scared of Hiawatha at this point) and had done zero buildup. Dido decides to dogpile against Gustavus, and the Huns dogpile against Hiawatha. A fun little war with no clear results.

The T157 Huns attack on Portugal was very sensible and well executed.

The T189 Gustavus war on Hiawatha was about as sensible as the first though at least he tried building up this time (to mere parity).

My T201 war produced a reasonable amount of warmongering penalty and was over quickly.

The T217 Dido war against Isabella made absolutely no sense despite a clear military advantage. She was nowhere near Isabella outside of a cross-ocean invasion. Nothing predictably happened. Guess this is a "diplomatic war"?

The T230 Gustavus war against presumably Babylon (despite the DoW going to Lizzy) was at least prefaced with a buildup and a marginal military advantage, but bringing in Dido against him, who has been the military powerhouse of the game and a neighbor of his, looks misjudged. I watched some of this, and a meager effort to invade Babylon was attempted, though he didn't seem to put too much pressure to bear on Babylon. I didn't see the Dido side of the war.

The T238 Huns war against Inca (DoW went to Isabella) made perfect sense and they had a clear military advantage going in, though without any buildup beforehand. I watched a bit of this, and there was at least a good deal of fighting at the border.

The T243 war of Dido was against Pocatello mostly it seems, though Inca got the DoW. Dido did a huge buildup and had clear military superiority over Pocatello, though not with the Inca included (they are all 3 neighbors) - Inca seems to have not gotten involved much. The outcome of her totally wrecking Pocatello was a foregone conclusion.

The T244+ war of Lizzy against Isabella was sensible, she had a rapid buildup and clear advantage going in, and none of the other civs were nearby, but she got wrecked with a quickness. The T268 war against Sejong when she was already at war and heavily beat up made no sense, and Babylon was just a few tiles shy of being her neighbor to boot and quickly marched an army through Sejong to get to her and mess her up more (one instance of a DP actually resulting in real help). The T272 DoW against me was sheer pointless madness, I guess a diplomatic war. We are not neighbors (for now).

The final bit of insanity is Sejong's DoW against me. I suppose he figured I was preoccupied with the Huns and Dido, however Dido should have been completely discounted as she was half a map away. It just opened Sejong up for me to march to his capital. I had a stack of negative penalties from him by this point, so it made sense in terms of basic diplo mechanics as well. I suppose we can't fault the AI for not realizing a human will take a DoW as an open invitation to their capital. It made sense if I was an AI.


Conclusions:

Overall, the AI is choosing DoW targets wisely vis-a-vis DPs, using the weakest link in the DP chain as their DoW target, even if the intended target is another member of the DP. The AI is doing a mixed job of actually preparing for wars or for choosing wars with a clear military advantage for itself. Gustavus and Lizzy were particularly atrocious at this, while the Huns and Dido managed their targets very well. Unsurprisingly, the latter group has expanded well into dominant positions. Gustavus and Lizzy appear to be insane from a strategic-diplomatic point of view. Something needs to be reined in there - the Huns should not be the sensible moderates in the room. It was nice to see some civs were totally peaceful, like Isabella, Pocatello, and Babylon, while others were constantly stirring things up, like Dido, the Huns, Gustavus, and later Lizzy. Inca took one opportunistic dogpile early on and kept to themselves otherwise.


Sejong's DoW against me, while it made sense in terms of our relations (lots of tensions), ended up being a huge blunder, and seemed more for diplomatic points than anything else.

The instances of the AI declaring aggressive war and basically not doing anything either to invade seriously or build up their military were constant, and one of the weakest points currently. If the AI is going to war, they need an actual army that can win a war and to then actually use that army from the get-go. Especially against a human. The Huns and Sejong both DoWd me without a clear plan of assault. The Huns had at best a fifth of their military nearby me, and sort of just shuffled 3-4 units at me at first, easily repelled, then just shot random 1-3 unit piles at me after that, also easily repelled. Sejong DoWd me and literally sent nothing at me and had his closest city on my border guarded by like a single pikeman and hwatcha. The path to Seoul is wide open right now for me.

It seems sometimes the AI does a huge military push with clear advantage, and sometimes just flubs it, even when clearly aggressing. I've been wrecked by dogpile AIs (prior game) and had them just sort of sit around waiting for me to attack back.

On map, I'm Russia. Portugal was my southern 2 cities, Pocatello was far West, now Dido.
 

Attachments

  • Untitled.png
    Untitled.png
    42.1 KB · Views: 284
Game ended poorly after I took out Seoul. Warmonger penalties were extreme at that point (I think -200 for one), plus I was again getting wonderspam penalties in the -40 range despite a very middle of the pack amount. Seems very unbalanced on the latter.

I fought an endless stream of defensive wars after that point, alongside sanctions, against England, Spain, Attila again, and Hiawatha. I still managed to turn them all away and get my economy into shape for a late-game run at a time victory (I generally ignore VCs, and with so many AIs on the map the game usually doesn't get far enough along anyway).

And then the grand finale: a triple team from Hiawatha, Spain, and Babylon out of nowhere (friendly entire game, he just flipped on a dime late-game). That was too much to handle, and I peaced out with half my cities.

Never really got a chance to cool down the warmonger penalties. It seems you have to either have a great strategic position and keep a massive army around, or be very sparing with conquest. Being in the middle of civs makes you an endless target, and taking more than a couple cities makes your diplo penalties ridiculous.

Certainly, I could have just sat back and tried to build away post-Portugal conquest, but I doubt the end result would've been different. Isabella was gobbling up everyone around her and I was next in line, Hiawatha hated me all game especially after Portugal, and Babylon flipped last-minute from lifelong-superfriend to worst enemy which is obnoxious.

Not quite sure how to handle this mod now. This is the second game where a giant dogpile ended the game short (well T450 in this case at least). It's great in terms of AI aggressiveness, but actually managing diplomacy is a lot more... chaotic and key aspects seem locked out for me (DPs and trading DoWs).

At least I have unwinnable wars again. I just wish there was a clearer path to avoiding those outcomes other than "never take territory yourself".
 
Is there a way to tweak these values ourselves?

I agree that too much expansion or wonder spamming could accrue diplo penalties but I don't think it should be that high. I had -200 from building wonders by late game and I wasn't even the highest wonder builder in the game.

Building wonders are already restrictive and need a lot of planning/decision making. (ie. no. of policies needed, policy finishers, city plot/terrain requirements, production penalty from previous wonders).

If I manage to beat the AI to a wonder despite all this, it's a big achievment and so satisfying and ultimately fun.

It seems anti-fun to be punished for "winning a race". A race where I am blindfolded, running one legged, with a weight attached to me lol

Again I don't think I should get NO diplo penalty, but just not so extreme.
 
Top Bottom