AI and Stratagems
Having room for complex strategy in combat presents the problem of how to produce AI capable of competing with a human player.
Firstly I would like to state that I think AI in games should prioritise being entertaining to play against and not just prioritise beating the player. Being relentlessly stomped on by an AI that uses the same tired strategy every time is no fun compared to one that is willing to take risky strategies to entertain and surprise the player.
Somewhat fortunately the battle system presents a problem that is difficult to solve optimally as it is somewhat meta averse, in that if a certain strategy becomes more popular, then the counter to this strategy increases in value, as such strategies circularly balance out similar to “rock-paper-scissors”.
The core battle AI implementation I have opted for is based on Stratagems. Stratagems are simply a sequence of moves that synergies well together. A simple example being a stratagem that buffs fire attacks and then follows that up by using a fire attack that would benefit from the buff.
All of the stratagems are hand made and so use a human level of intelligence, giving a more entertaining challenge. The battle AI can then evaluate a list of useable stratagems and then uses a probabilistically weighted selection to pick one, with the higher rated stratagems being more likely to be selected.
The evaluations themselves are comprised of two parts. An initial move evaluation where a moves effectiveness is evaluated by itself and then this is combined with the stratagem effectiveness modifier which represent the value gained by the synergy the stratagem provides over selecting random moves. The evaluation calculation for the stratagem is hand created for each stratagem (and as such can be altered to balance the AIs preference to certain stratagems), but the core move evaluation is based on a emulated use of the move on a test copy of the target creature, the damage and status effects inflicted on the test creature are then evaluated. This evaluation takes into account many factors such as the target’s health, attack speed and status effects applied (e.g. debuff and buff are more effective when starting as such get higher ratings when the target’s health is high).
The stratagems can also be either specific or abstract. Where specific stratagems will refer directly to a certain sequence of exact moves that the creature must have in order to make use of the stratagem. Abstract stratagems can provide move analysis to find moves in the creatures arsenal that match the desired stratagem. For example, the 'One Two Punch' stratagem that searches the creatures attack move sets in order to find complementary fast attack and heavy attack. It will then instruct the creature to use the fast attack first, so that it does not move too far along the combat time line and then use the heavy attack. If the right opportunity arises then the stratagem could incapacitate an opponent without allowing them any further attack, where any other move sequence may not. The evaluation of the stratagem looks out for these opportunities to be used optimally and will increase the evaluation rating dramatically.