Every AI player chooses a set of strategies according to its personality and the current situation in the game. There are 20 different strategies, iiuc they mainly determine what the AI chooses to build in its cities, how it adjusts its sliders and how it behaves when it comes to starting wars:
- AI_STRATEGY_DAGGER
- AI_STRATEGY_SLEDGEHAMMER
- AI_STRATEGY_CASTLE
- AI_STRATEGY_FASTMOVERS
- AI_STRATEGY_SLOWMOVERS
- AI_STRATEGY_CULTURE1
- AI_STRATEGY_CULTURE2
- AI_STRATEGY_CULTURE3
- AI_STRATEGY_CULTURE4
- AI_STRATEGY_MISSIONARY
- AI_STRATEGY_CRUSH
- AI_STRATEGY_PRODUCTION
- AI_STRATEGY_PEACE
- AI_STRATEGY_GET_BETTER_UNITS
- AI_STRATEGY_LAND_BLITZ
- AI_STRATEGY_AIR_BLITZ
- AI_STRATEGY_LAST_STAND
- AI_STRATEGY_FINAL_WAR
- AI_STRATEGY_OWABWNW
- AI_STRATEGY_BIG_ESPIONAGE
Everybody starts with AI_STRATEGY_PEACE in the beginning, but this actually has no effect on anything (nothing implemented in the code). As mentioned earlier in this thread there is some pseudo randomness in the form of the iNonsense variable which depends on the position of the AI's capital on the map (it's the sum of the capital's X and Y coordinates, so it is fixed for the whole game as long as the capital isn't moved). Its influence is mostly implemented in the form x = y + (iNonsense%z), with % being the modulo-operator, so it allows variation in the range [0...(z-1)].
The requirements for AI_STRATEGY_DAGGER are:
general:
- not AI_STRATEGY_MISSIONARY
- "early" in the game ( iCurrentEra <= (2+(iNonsense%2)) which means upto Medieval / Renaissance )
- must have met others
- must have iParanoia > 0 (due to the self-closeness bug this is always true after the AI has made contact with someone it is cautious or lower with)
Leader's personality:
- MWR = MaxWarRand, FM = AI_FLAVOR_MILITARY, NF(NonsenseFactor) = (iNonsense % 11)/10 :
- iDagger = 120 * 100/(MWR+50) * NF + 5 * Min(8, FM);
Example: Ragnar MWR = 50, FM = 10, Nidaros @ (X=30,Y=31) --> iNonsense = 30+31 = 61; NF = (61 % 11) / 10 = 0.6
iDagger = 120 * 100/(50+50) * 0.6 + 5 * Min(8, 10) = 72 + 40 = 112;
iDagger is further modified for military Unique Units (all except Indian Fast Worker):
AggAi off? +5 / +10 / +15 for Prince / Monarch / Emperor+
already at war (AREAAI_OFFENSIVE, AREAAI_DEFENSIVE)?
- +40 if capital can build offensive units (UnitAIs: RESERVE, ATTACK_CITY, COUNTER, PILLAGE)
- +20 if capital cannot build offensive units (-->AI_STRATEGY_GET_BETTER_UNITS)
CHECK: iDagger >= AI_DAGGER_THRESHOLD (100) --> AI_STRATEGY_DAGGER!
So all the warmongers with strong offensive UUs are likely to follow Dagger strategy until medieval/renaissance era.
Example1: Ragnar from above can build Berserkers in Nidaros, AggAI off Immortal difficulty, not at war
iDagger = 112 + 40 + 20*0 + 15 = 167 >= 100 --> AI_STRATEGY_DAGGER
Example2: Willem (MWR=100, FM=0), Amsterdam @(44,12) can build East Indiaman, AggAI off Deity difficulty, not at war
iDagger = 120 * 100/(100+50) * 0.1 + 5 * Min(8, 0) = 8 + 0 = 8; for personality
iDagger = 8 + 40 + 20*2 + 15 = 103 >= 100 --> AI_STRATEGY_DAGGER
Example3: Gandhi (MWR=400, FM=0), Delhi @(22,21), AggAI off Prince difficulty, currently fighting defensive war, can build Musketmen (UNITAI_RESERVE)
iDagger = 120 * 100/(400+50) * 1 + 5 * Min(8, 0) = 13 + 0 = 13; for personality
iDagger = 13 + 5 + 40 = 58 < 100 --> no Dagger
When it comes to war, IMHO the main effect of AI_STRATEGY_DAGGER is the skipping of the preparation phase, which means that Dagger-AIs that changed war plans to Limited or Total Wars will never call those plans off again (so Saladin was no Dagger in ALC#24). I'm not really sure about what determines the interval between the war plan change and the actual DoW (=you get WHEOOHRN before the war). I guess it depends on where their SoD is located and how long it takes to march it to your borders (DoW = crossing borders). If there are any obstacles in the SoD's path (like impassable mountains) it could be that the AI is locked in WHEOOHRN forever.