Picks a primary and a secondary victory pursuit.
[STEP 1. What options are available?]
- If the No Science game option is disabled, Science pursuit is a valid option.
- If the No Policies game option is disabled, Culture pursuit is a valid option.
- If the No Leagues game option is disabled, Diplomatic pursuit is a valid option.
- If the Always Peace game option is disabled, Domination pursuit is a valid option.
If no options are valid, set primary and secondary victory pursuit to NO_PURSUIT and exit.
If one option is valid, set that option as the primary victory pursuit, set the secondary victory pursuit to NO_PURSUIT, and exit.
[STEP 2. Eternal Victory Pursuit]
If the AI has an override to always pursue a specific victory condition (if enabled; in Domination Victory's case, it is valid if it's possible to eliminate all other players), set it now.
Overrides can be set individually for a leader by setting one of the following flavors to -12:
- Boldness (Domination)
- MinorCivCompetitiveness (Diplomatic)
- WonderCompetitiveness (Culture)
- WarmongerHate (Science)
Overrides can also be set globally by setting Limit Victory Pursuit Randomization to 3 in DiploAIOptions.sql.
The global override, if for a valid victory condition, takes precedence over the individual override. It will not take effect if the leader has no primary victory pursuit defined in XML.
The primary victory pursuit is set to the override, and the secondary victory pursuit is set to NO_PURSUIT. Then exit.
[STEP 3. Retrieve Pursuit Hints from XML]
Each civ can have a primary and secondary victory pursuit hint in XML. These hints tell the diplo AI which victory pursuit it would be best suited for.
If Random Personalities was enabled *and* more than 2 valid pursuit options are available, then the personality type is used instead of the leader type when retrieving these hints.
If the modder has specified no primary hint but has specified a secondary hint, the primary hint becomes the secondary hint, and the secondary hint becomes NO_PURSUIT.
If the primary and secondary hints are the same, the secondary hint becomes NO_PURSUIT.
It is possible for there to be no pursuit hints, for generalist civs.
[STEP 4. Are only two options available?]
Determine what those two options are.
If one of the options is the primary hint, pick that option as the primary pursuit and the other one as the secondary pursuit.
Otherwise, if one of the options is the secondary hint, pick that option as the primary pursuit and the other one as the secondary pursuit.
If we haven't picked pursuits yet, access player traits and run the following checks in this order of priority:
1. If Domination is a valid pursuit and this civ's UA grants warmonger bonuses, pick Domination as the primary pursuit and the other option as the secondary pursuit.
2. If Diplomatic is a valid pursuit and this civ's UA grants diplomacy bonuses, pick Diplomatic as the primary pursuit and the other option as the secondary pursuit.
3. If Culture is a valid pursuit and this civ's UA grants culture bonuses, pick Culture as the primary pursuit and the other option as the secondary pursuit.
4. If Science is a valid pursuit and this civ's UA grants science bonuses, pick Science as the primary pursuit and the other option as the secondary pursuit.
5. If Domination is a valid pursuit and this civ's UA grants bonuses to wide play, pick Domination as the primary pursuit and the other option as the secondary pursuit.
6. If Diplomatic is a valid pursuit and this civ's UA grants bonuses to wide play, pick Diplomatic as the primary pursuit and the other option as the secondary pursuit.
7. If Culture is a valid pursuit and this civ's UA grants bonuses to tall play, pick Culture as the primary pursuit and the other option as the secondary pursuit.
8. If Science is a valid pursuit and this civ's UA grants bonuses to tall play, pick Science as the primary pursuit and the other option as the secondary pursuit.
If we still haven't picked pursuits yet, the primary pursuit is picked with this order of priority (only considering valid options)...
1. Domination
2. Diplomatic
3. Culture
4. Science
...and the other option is picked as the secondary pursuit.
Exit the function now.
[STEP 5. Human Victory Pursuit Selection (3+ Valid Options)]
Only run this step if the player is currently a human.
If the secondary hint is not a valid pursuit, set the secondary hint to NO_PURSUIT.
If the primary hint is not a valid pursuit, set the primary hint to NO_PURSUIT. However, if the secondary hint is a valid option, use the secondary hint as the primary hint, and then set the secondary hint to NO_PURSUIT.
After this validity check, if there is a primary hint, pick that as the primary pursuit. If there is a secondary hint, then pick that as the secondary pursuit, otherwise don't pick a secondary pursuit.
If we haven't picked pursuits yet, access player traits and run the following checks in this order of priority:
1. If Domination is a valid pursuit and this civ's UA grants warmonger bonuses, pick Domination as the primary pursuit.
2. If Diplomatic is a valid pursuit and this civ's UA grants diplomacy bonuses, pick Diplomatic as the primary pursuit.
3. If Culture is a valid pursuit and this civ's UA grants culture bonuses, pick Culture as the primary pursuit.
4. If Science is a valid pursuit and this civ's UA grants science bonuses, pick Science as the primary pursuit.
5. If Domination is a valid pursuit and this civ's UA grants bonuses to wide play, pick Domination as the primary pursuit.
6. If Diplomatic is a valid pursuit and this civ's UA grants bonuses to wide play, pick Diplomatic as the primary pursuit.
7. If Culture is a valid pursuit and this civ's UA grants bonuses to tall play, pick Culture as the primary pursuit.
8. If Science is a valid pursuit and this civ's UA grants bonuses to tall play, pick Science as the primary pursuit.
In all of these cases, no secondary pursuit is picked.
If we still haven't picked pursuits yet, the primary pursuit is picked with this order of priority (only considering valid options)...
1. Domination
2. Diplomatic
3. Culture (Science in Community Patch only)
4. Science (Culture in Community Patch only)
In all of these cases, no secondary pursuit is picked.
Exit the function now.
[STEP 6. AI Scoring of Victory Pursuits (3+ Valid Options)]
Random = a random number between 1 and 10 (1 and 20 if Random Personalities are enabled), re-randomized each time.
All four victory pursuit scores start at 0.
A. Base Weights
- Base weight for Domination pursuit = (Highest of WAR and HOSTILE biases) - (Highest of FRIENDLY and AFRAID biases)
- Base weight for Diplomatic pursuit = (Highest of DECEPTIVE and FRIENDLY biases) - (Highest of WAR and HOSTILE biases)
- Base weight for Culture pursuit = (Highest of NEUTRAL and FRIENDLY biases) - (Highest of HOSTILE and GUARDED biases)
- Base weight for Science pursuit = (Highest of NEUTRAL and GUARDED biases) - (Highest of WAR and DECEPTIVE biases)
B. Domination Weight
If Domination isn't a valid pursuit, set score to -100. Otherwise...
- Add Boldness to the score.
- Add Meanness to the score.
- Add Offense flavor / 2 (rounded down) to the score.
- Add Expansion flavor / 2 (rounded down) to the score.
- Add Random to the score.
C. Diplomatic Weight
If Diplomatic isn't a valid pursuit, set score to -100. Otherwise...
- Add DiploBalance to the score.
- Add MinorCivCompetitiveness to the score.
- Add Diplomacy flavor / 2 (rounded down) to the score.
- Add Gold flavor / 2 (rounded down) to the score.
- Add Random to the score.
D. Culture Weight
If Culture isn't a valid pursuit, set score to -100. Otherwise...
- Add DoFWillingness to the score.
- Add WonderCompetitiveness to the score.
- Add Wonder flavor / 2 (rounded down) to the score.
- Add Culture flavor / 2 (rounded down) to the score.
- Add Random to the score.
E. Science Weight
If Science isn't a valid pursuit, set score to -100. Otherwise...
- Add Loyalty to the score.
- Add WarmongerHate to the score.
- Add Science flavor / 2 (rounded down) to the score.
- Add Growth flavor / 2 (rounded down) to the score.
- Add Random to the score.
F. Pursuit Hints
- If there is a primary pursuit hint and no secondary pursuit hint (in XML), add 8 to the primary hint's pursuit.
- If there is a primary pursuit hint and a secondary pursuit hint (in XML), add 5 to the primary hint's pursuit and 3 to the secondary hint's pursuit.
G. Factor in Number of City-States
- If there are more major civs ever alive than City-States in the game, subtract 5 from Diplomatic pursuit.
- If the number of City-States in the game is <= half the number of major civs ever alive (rounded down), subtract another 5 from Diplomatic pursuit.
H. Disabled Victory Conditions
- If Domination Victory is disabled, subtract 10 (15 if Random Personalities is enabled) from Domination pursuit.
- If Diplomatic Victory is disabled, subtract 10 (15 if Random Personalities is enabled) from Diplomatic pursuit.
- If Culture Victory is disabled, subtract 10 (15 if Random Personalities is enabled) from Culture pursuit.
- If Science Victory is disabled, subtract 10 (15 if Random Personalities is enabled) from Science pursuit.
I. Sort The Scores
Sort the scores from highest to lowest. If two or more scores are tied, they are listed in the order: Domination, Diplomatic, Culture, Science (this is relevant in the next step).
[STEP 7. AI Selection of Primary Victory Pursuit]
If the Limit Victory Pursuit DiploAIOption is enabled, the AI will always pick their primary victory pursuit hint from XML here unless that victory condition is disabled or unachievable.
If there is one victory pursuit with the highest score, that one is selected.
If the top two scoring options are tied after Step 5 (note: it only considers the top two even if there's a 3- or 4-way tie):
- If one of the options is the primary pursuit hint, pick that one as the primary pursuit.
- If one of the options is the secondary pursuit hint, pick that one as the primary pursuit.
If we haven't picked pursuits yet, access player traits and run the following checks in this order of priority:
1. If the first option in the list is Domination and this civ's UA grants warmonger bonuses, pick Domination as the primary pursuit.
2. If the first option in the list is Diplomatic and this civ's UA grants diplomacy bonuses, pick Diplomatic as the primary pursuit.
3. If the first option in the list is Culture and this civ's UA grants culture bonuses, pick Culture as the primary pursuit.
4. If the first option in the list is Science and this civ's UA grants science bonuses, pick Science as the primary pursuit.
5. If the second option in the list is Domination and this civ's UA grants warmonger bonuses, pick Domination as the primary pursuit.
6. If the second option in the list is Diplomatic and this civ's UA grants diplomacy bonuses, pick Diplomatic as the primary pursuit.
7. If the second option in the list is Culture and this civ's UA grants culture bonuses, pick Culture as the primary pursuit.
8. If the second option in the list is Science and this civ's UA grants science bonuses, pick Science as the primary pursuit.
9. If the first option in the list is Domination or Diplomacy and this civ's UA grants bonuses to wide play, pick the first option in the list as the primary pursuit.
10. If the first option in the list is Science or Culture and this civ's UA grants bonuses to tall play, pick the first option in the list as the primary pursuit.
11. If the second option in the list is Domination or Diplomacy and this civ's UA grants bonuses to wide play, pick the second option in the list as the primary pursuit.
12. If the second option in the list is Science or Culture and this civ's UA grants bonuses to tall play, pick the second option in the list as the primary pursuit.
13. Pick the first option in the list as the primary pursuit.
[STEP 8. AI Selection of Secondary Victory Pursuit]
SCENARIO 1: The chosen primary pursuit is the same as the primary pursuit hint in XML.
If there is a secondary pursuit hint AND that pursuit is a valid option AND that pursuit's victory condition isn't disabled AND Random Personalities isn't enabled:
- Pick the secondary pursuit hint as the secondary pursuit.
SCENARIO 2: Scenario 1's conditions were not met, and Limit Victory Pursuit Randomization is set to 2.
- Do not pick a secondary pursuit.
SCENARIO 3: The chosen primary pursuit is different from the primary pursuit hint in XML, but there is a primary pursuit hint in XML (not NO_PURSUIT).
If the primary pursuit hint's pursuit is a valid option AND that pursuit's victory condition isn't disabled AND Random Personalities isn't enabled:
- Pick the primary pursuit hint as the secondary pursuit.
SCENARIO 4: There is no primary (or secondary; see above) pursuit hint in XML, OR the pursuit hint was invalid in Scenario 1 or 3.
If the chosen primary pursuit was the option with the highest score (or the first listed option, if there was a tiebreaker):
- Pick the runner-up (or the second listed option) as a secondary pursuit.
- Otherwise, pick the option with the highest score (or the first listed option) as a secondary pursuit.