Strategy guidelines for AI


Jan 9, 2016
I am checking some mechanisms available already in the game that would allow to implement more sophisticated strategies for the AI. Basically the idea is to be more mindful about the situation in the game especially what opponents are doing and better evaluate our chances. Based on that the AI could really focus on specific aspects of the game and pursue a specific victory much better than now.

In this thread I would like to discuss the conditions that should / could drive the AI for pursuing specific victories and their priorities.

As an example, let me tell you how the AI determines e.g. that it wants to pursue a Science Victory right now. 3 conditions out of these 6 must be true:
  • Good Tech City
  • Is Renaissance
  • Has 2 science wonders
  • Has tech lead at 33 (unclear what that measures, most likely total science yield must be 33% more than the world average) Edit. After some testing: it is a top percetile of civs ordered by number of techs.
  • Lags military by 33 (same as above, probably 33% less military strength) Edit. Probably bottom percentile.
  • Finished Satellite Launch
Seems reasonable at first, but the problems are:
  • The conditions fluctuate, so until some permanent conditions are met, the strategy is being activated and deactivated, every several turns.
  • Mid-game, after Renaissance, practically all Civs follow that strategy - because every one has at least one good city and the era hit.
  • Other strategies have similarly looking conditions, so being an average puts a Civ at a disadvantage because none strategy will activate and the civ is forever doomed to be average.
  • No considerations about the game situation and what other players are doing.
  • No considerations about leader traits or civ affinity. The Science victory activates as a result of various random actions, not as a semi-consious drive to achieve the goal.
As a comparison, in Vox Populi mod, the Science Strategy checks for:
  • Civ flavors and traits.
  • Tech lead - including considerations of others.
  • Game progress and probability of loosing vs. wining.
  • What policies we acquired, what buildings / wonders are in the empire.
  • Religion influence.
  • Guessing strategies of other players and setting our priorities accordingly.
Same goes for other victories, the conditions are very simple and results are similar. The biggest problem is the lack of strong focus late game and constant turning on/off which leads to inconsistent behavior and opportunity costs.

So, assuming that the above could be re-programmed, whould do you imagine could / should be the considerations of the AI concerning specific victories in various stages of the game?
Or to rephrase the question - how do you determine what victory to pursue and what information from the game do you use.
Last edited:
I'm not a programmer, so please take the following suggestions with that in mind and ignore as appropriate. :)

I think every civ should have a victory condition in mind at all times, and should be pursuing that victory condition until it has reason to switch to another victory condition.

For this reason, I'd suggest a "points tally" system, where the number of points arguing towards each of the victory objectives is tracked, and a civ only switches if the points score for another objective exceeds the points score for the current objective.

As to what factors should provide points, I'd base that off of what factors are easiest for the system to score. A starting preference for each civ would be appropriate. For example:
  • Robert could be 2 points in Science, 1 point in Culture to start with, so that he has both a first preference and a second preference
  • Genghis could be just 1 point in Domination, so he has a small preference and no particular secondary preference
  • Seondeok could be 3 points in Science, so she has a strong preference and is unlikely to move away from it unless a lot of unusual factors line up
I think early game would have to depend on things like leader traits, terrain, and city states met. Maybe a leader with some science bonus who meets a nearby science city state (well, one that they don't conquer anyway) should focus on science. In the midgame, they should probably continue focusing on science unless they fall quite behind in tech.

I think the focus established in the early game should continue throughout the game unless circumstances dramatically change. Perhaps you can include some type of 'win chance' calculation in later eras. If the win chance following their current strategy falls below x%, then they shift to a different strategy. Probably a condition like 'if win chance is below x% for every victory, declare war on player with highest win chance in your most likely victory condition' would be necessary to prevent middling civs from drifting aimlessly without a strategy.
I've tested the above mentioned mechanisms and they do work. It is possible to turn ON and OFF various strategies practically at will, based on any logic coded in a Lua script. It means that it is possible for AI to focus on a specific path, change it or even employ counter-strategies if necessary. One must remember however, that as for now the only thing that can be modded in regards to the execution of those strategies (once they are activated) are priorities for various things like yields, pseudo-yields, civcs, techs, wonders, unit types, diplo actions, etc. stored in AiFavoredItems.
It is possible to turn ON and OFF various strategies practically at will, based on any logic coded in a Lua script.
Yes, this is common knowledge we have an example for this in Poland scenario:
StrategyType="STRATEGY_POLAND_RAPID_EXPANSION" ConditionFunction="Call Lua Function" StringValue="HasFourCities" Disqualifier="true"
Top Bottom