AI POST (ongoing)
Philosophy
The AI must be as simple as possible and yet allow the strongest possible play. There are two things that lose games: stagnation (no discarding) and weak card placement. The current AI fails on both counts. The solution is to consistently discard weak cards and play only strong ones.
Variables
(hand slot 1-5) RANK 1-4 (private, corporal, sergeant, captain), FAMILY 1-20, RELATION slot ,0 (slot 1-5 is hand, 6-9 is board), RELATION TYPE 1-6 (private-corporal, private-sergeant, corporal-sergeant, sergeant-sergeant, captain-captain, useless)
(board postion 1-4) STATUS 0-3 (empty, occupied, locked, maxed; 1-2 is front row, 3-4 is back row) (locked can be used as a tiebreaker)
(board flags) FRONT_MAX 0-1 BACK_MAX 0-1, MAGE 0-1, MERLIN 0-1, BUILD 0-1
(card value) spawn cost, ties are resolved by life+attack+defense. further ties are resolved with the higher family number being stronger, final tie is broken by card farthest to the right in the family is stronger.
Logic Flow
Board Scan
(Mage Scan) If there is an enemy mage (multiple simultaneous square attacks) on the board then MAGE is true and run MAGE.
(Emergency Scan) If total life left is <100 and there is a single enemy attacking an empty slot with an attack strength of 7 or more then EMERGENCY is true and run EMERGENCY.
(Injured Scan)
(Maxed Scan) if either both front rows or both back rows have fully evolved cards then the row is MAXED. A slot is also maxed if an evolved card's evolution card is not anywhere in the draw pile. If both rows are MAXED then all AI actions are aborted and the AI just hits spacebar.
Hand Scan
(Merlin Scan) If Merlin is present in the hand, immediately BUILD is true.
Discard Actions (trash and/or board)
1. If the front or rear rows are MAXED then run the modified MAXED scan.
2. If BUILD is in progress then run the BUILD routine.
3. Scan latest draw for direct relation to any card on the board; if direct relation is found then run BOARD_BUILD. Scan each hand slot. With each check for relation with each other card slot; if there is a relation then code the slot appropriately. If relation of 3-5 is found then BUILD is true and run BUILD routine. If all cards are at least sergeant then run TRAFFIC_JAM. If there is an empty slot, hit spacebar otherwise discard with the following priority: 1) lowest value private card with no relation, 2) lowest value corporal card with no relation, 3) lowest value private card with relation
(Red mage must be played on the rear squares or discarded)
BUILD
if spawn points < build cost and a slot is open then hit spacebar.
(survival scan) Survival means the ability to take more than one hit.
(stagnation scan)
(placement strategy will be against the most evolved or secondarily the highest family with survival being assured, otherwise with the slot that allows survival)
(if a mage is being played, placement will be on unoccupied squares or those with least offensive attack)
MAGE
(healer scan must also be performed)
(non-mage mage assassin must have at least 3 offense)
(fire knight and master cleric cannot be a mage assassin)
(mage assassin should be the highest evolved possible currently in the hand)
TRAFFIC_JAM
Play the most evolved captain otherwise discard with the following priority: 1) lowest value sergeant without relation, 2) captain which is lower than a current build, 3) The lowest value card from the lowest value build