Dulst comes with an AI system that can play any game.
Animal Kingdom comes with the system already set up to play the game and any derivatives at a high level. This article explains how it works and how to customize it for different games.
How it works
The AI is given a list of possible moves and a scoring system that determines the quality of moves. The AI will run simulations of those moves and choose the move with the best score. The system is generally strong. For the purposes of most games, providing singleplayer experiences, tutorialing, boss fights, etc it is more than sufficient.
Implementation
Look for the ai section of the rule cards. The key card is "make moves". If it's the ai player's turn, that card will run the "run sim" action, which triggers AI play. Read the description for each card in the AI section. They all have useful information that teach you how to setup and customize your own AI.
List of moves
All types of cards are triggered by activating the "click" event on them. Cards in various locations respond differently to clicks as determined by the rule cards. Clicking an animal on board starts the attacking sequence while clicking on one in hand starts the playing sequence. The "get possible moves" rule finds these cards and add them as possible moves to the game.
Playable cards are found each turn by checking for eligibility. Cards are marked as "eligibleToPlay" "eligibleToAttack" and "eligiblePower" each turn by the Set Eligibility game rules. This marking highlights the cards as playable for both the human player and the AI.
The end turn button is recognized as a card by the AI and can be clicked on the same as any other card.
Scoring
The purpose of scoring is to figure out what the best possible move the AI can make. The AI will play simulations of possible moves and present each resulting gamestate to you to score. The gamestate with the highest score will be the move it actually makes. The score gamestate card takes into account all the vital details of what makes a winning position such as the quantity and quality of cards the ai has over its opponent, board initiative, hero health, and max mana. You can improve on the scoring by editing the config values or adding your own dimensions to consider. If you add additional features to the game they should be added to the scoring as well.
Limitations:
- The AI cannot accurately and automatically measure the power of cards whose effects apply in multiple turns down the line. In those cases, special scoring must be made for those cards. If you plan on making the AI play complicated decks with many such cards, you should make the effort to do so.
- The AI currently do not make intelligent decisions on the opponent's turn (it is too disruptive to wait). The AI will always choose the first choice if asked. Similarly, if the AI the middle of its turn plays a card that makes the human opponent choose, it'll always assume the opponent chooses the first option during its calculations. The human opponent will get a chance to make a decision during its real turn but if the decision is different this may throw off the game. The recommendation therefore is to avoid making cards that have cross-player decisions during one player's turn or have their effects not be visible or delayed.
- The AI is only as smart as your scoring system. Machine learning can supercharge your scoring system and make it stronger, however this is not yet available in this version of Dulst.
- The AI is specifically programmed by default to not consider all the positioning options when doing a drag and drop onto a board position. To make the AI consider positions (costs performance), enable the AI_POSITION option on on that card's custom properties. Fox is an example of a card with that option.
Performance: The strength of the AI is controlled by several settings on the AI rule cards. The settings are all explained on the make moves card. Generally, the smarter the AI is, the slower it is. It's a trade-off between turn thinking time and speed. Over time performance should increase as Dulst updates.