The first 10 categories are fairly straightforward. The AI looks at the current state of the game (how much culture/armor/attack/economy each player has and what round it currently is) and tries to find the card that will best benefit it.

Abilities

The last 7 categories attempt to handle Abilities, which are trickier. It is assumed that the cost of each card is fair and accurately reflects its value under ordinary circumstances, so the AI is basically looking for extraordinary circumstances to take advantage of. If it has a lot of Infantry cards, then Shieldwall is a high value card since that ability represents a combo opportunity with Infantry cards.

Categories 11-16 (combos and counters) handle most card abilities, and for a long time that seemed okay enough. But it eventually became obvious that for some cards it’s harder to describe what a combo or counter is, and so category 17 was added to provide custom logic for those cards. Examples include Plaguebearer, Master Thief and The Oracle. These are cards that you should only buy under very specific circumstances, and if the AI buys one when it shouldn’t, it can ruin the illusion of intelligence completely. About 25 cards have such custom logic.

The first version of the AI probably only had about half of these categories. Whenever I embarked upon a series of AI improvements, I would simply play a game and wait for the AI to do something that seemed obviously sub-optimal, and then I would analyze its logic to figure out why it made that choice. This usually resulted in a re-write of a category, the addition of a new one, or the adjusting of weights.

Assigning Damage

Combat damage assignment follows a similar pattern, but with only 10 categories. The AI randomly assigns damage and then calculates the total value of the cards left over. It does this 1000 times and then picks the permutation that resulted in the highest total value. I probably could have done this in a more rigorous way, but in practice it seemed to work pretty well so I never improved it.