Okay. Since I promissed to present some more ideas, let me do just that. Here are some of my rough design ideas for this AI mod.
First, we have to define some terms. A
strategy is a sequence of approximate steps to achieve a goal. I know that some will argue that an AI that just follows a script like this is not a true AI, but to be honest that's the best that we can do. That's why we want human players to think and invent strategies. By
approximate I mean that the steps may be described only partially with unknowns left as parameters, and/or that there is an error margin. A
goal is a specific game state to achieve within an acceptable error margin.
With this in mind the system would work in roughly the following way:
Choose a goal
Choose a strategy that fits this goal
Follow the steps of the strategy
Each step in the strategy can of course have several more goals to choose from and several sub-strategies. The algorithm can be exectuted recursively as many times as needed.
Choosing an appropriate goal and strategy is relatively simple. For this we can use a point scoring system. We look at various
attributes of the game such as map settings, AI personality, and so forth, and assign a score to each of the goals/strategies with respect to that attribute. We can also add a random factor to the score for unpredictability. Then, we choose the highest scoring goal/strategy. Something like this:
Set the score for all goals/strategies to zero
For each goal/strategy
For each attribute
Add a score based on interaction of attribute and goal/strategy
Add a random factor
Pick the highest scoring goal/strategy
To be even smarter, one of these attributes could be based on what the opponents would do. We can run the algorithm again for all opponents to see what they would do and then assign a score to all the goals/strategies based on our opponent's decision. For those who know what I'm talking about, this works like the minmax algorithm.
The next step, following the steps of the strategy, is more tricky. Here I have to point out that we're still looking at the strategic level not the tactictical level. At the strategic level specific actions such as unit orders or build orders are not specified. Instead, the system enters into a
mode that affects its tactical level decisions. For example, if we are in "war mode" we are only going to produce military improvements and units and we are going to send our units on missions instead of just garrisoning them in cities. Or if we are in "expansion mode" we are going to produce settlers and workers and try to grab as much land as possible. Of course, these are just an examples to show how the mode affects tactics without dictating exactly what to do.
In addition, there have to be some
trigger conditions that change the state of the AI. When such a trigger condition is met the system chooses between one of several possible outcomes:
a) Go to next the step in the strategy
b) Retract to the previous step in the strategy
c) Re-evaluate the goal/strategy.
For example, if we are in "expansion mode" and there is no more unclaimed land then we move on to the next step. If we are trying to attack a neighbour and they rebuff our attack then we have to go to the previous step, build up our military. Or if we're loosing badly we might re-evaluate our strategy completely.
For now we don't have enough specific details about the game to say how the AI will make tactical level decisions, but I'm hoping that the default AI will be at least decent in this regard. This way we can concentrate on the strategy level first. But we have to wait and see.