GenericMadScientist

Forbidden Memories Hand AI

Feb 1st, 2018
1,900
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 10.91 KB | None | 0 0
  1. 'The spreadsheet' refers to https://goo.gl/jrHE4f
  2.  
  3. AI opponents can have a hand with more than 5 cards. The hand size is given by Hand Size in the spreadsheet. Note that for the game's checks of win by deck out or Exodia the AI is considered to have a hand size of 5.
  4.  
  5. The AI will always play a monster with its primary Guardian Star.
  6.  
  7. When I say the AI looks at visible player cards, I usually mean only face-up cards. However, if the opponent is one of Heishin 1, Pegasus, Heishin 2, Seto 3, DarkNite, or Nitemare, then this includes face-up and face-down cards.
  8.  
  9. When I say the AI lacks field control, I mean either only the player has a monster on the field, or both sides do and the base max stat plus field boost for the AI card with the highest true max stat is less than or equal to the same for the player's visible cards. In this case, I will use 'player's best card' to mean the earliest visible monster of the player's with the highest true max stat and 'AI's best card' to mean similarly for the AI's monsters.
  10.  
  11. Whenever the AI searches for a card with the lowest true max stat whether on the field or hand, cards with a true max stat of 9999 are ignored.
  12.  
  13. Whenever the AI is said to play a monster in the first free monster zone, it will do so if there is a free zone. However if there are no free monster zones, it will do the play on top of the monster with the lowest true max stat. If however all five of the AI's monster zones have cards with true max stat of 9999, then by the previous point they are all ignored and the game tries to play on top of the 0th monster zone. This causes a soft lock.
  14.  
  15. A combo play for our purposes is defined as a sequence of one or more distinct cards, where the first card is either in the AI's hand or a monster on the AI's side of the field, any subsequent cards are from the AI's hand, all attempted fusions result in a successful fusion or equipping, and if the combo play is just one card then it is a monster.
  16.  
  17. ================================================================================
  18.  
  19. The AI first goes through the list of burn spells in the following order:
  20. Sparks
  21. Hinotama
  22. Final Flame
  23. Ookazi
  24. Tremendous Fire
  25. For each one, if the player has no cards in their magic zone and the player's LP is low enough for the card to be lethal, the AI just activates it from the hand.
  26.  
  27. Next the AI checks if they are one of the low mages or Neku. If so, it then checks if the field is of the type given below. If not, they then check if they have the field spell needed to change it back and if so they will activate it from the hand.
  28. Ocean Mage, Sea
  29. Forest Mage, Forest
  30. Mountain Mage, Mountain
  31. Desert Mage, Wasteland
  32. Meadow Mage, Meadow
  33. Guardian Neku, Yami.
  34.  
  35. If the AI lacks field control, it jumps to LBL_AI_LACKS_FIELD_CONTROL.
  36.  
  37. Assuming now the AI has field control, the first thing it does is check if it should activate Harpie's Feather Duster from the hand. This can only happen if the AI has it in their hand and the player has at least one card in the magic zone. If these conditions are met, the AI's chance of using it is their Spell Probability from the spreadsheet.
  38.  
  39. The AI then has three options, which are labelled with LBL_IMPROVE_MONSTER, LBL_FIND_BEST_COMBO, and LBL_SET_MAGIC. If the AI's LP is below their Low LP Threshold from the spreadsheet, they go immediately to LBL_IMPROVE_MONSTER. Otherwise the AI chooses randomly between the three options. If the AI has total domination (the base max stat plus terrain boost of their card with the lowest true max stat is greater than or equal to the base max stat plus terrain boost of the player's visible card with the highest true max stat), then they use the probabilities from Total Domination Probabilities from the spreadsheet, else they use the probabilities from Lacks Total Domination Probabilities from the spreadsheet. Be aware that if the player has no monsters then the AI will automatically conclude they have total domination.
  40.  
  41. LBL_FIND_BEST_COMBO:
  42.  
  43. The AI looks at the available combo plays with maximum combo length equal to Max Fusion Length from the spreadsheet if the number of cards in the AI's deck is more than Critical Deck Size from the spreadsheet, else a maximum combo length of 2.
  44.  
  45. The combo plays looked at consist of both ones entirely consisting of cards from the hand (if the maximum combo length is at least 3) and ones consisting of fusing on top of a card already on the field (if the maximum combo length is at least 2). In the case of fusing on top of a card on the field, the card on the field is counted towards the combo length and the corresponding card in the hand cannot be part of the combo (the 2nd card in the hand cannot be used in a combo play on top of the card in the 2nd monster zone, for example).
  46.  
  47. Combo plays are mostly judged by the max stat of the result, but in an odd way. If the combo play consists of exactly 1 card on the field, the true max stat is used. If the combo play consists of exactly 1 card from the hand, the base max stat is used. Else the base max stat plus field boost is used. The combo play with the highest max stat value assigned in this way is used. Tie-breaks are very strange though.
  48.  
  49. For tie-breaks, the order in which the combos are looked at is important. Combos using earlier cards at the start are looked at first (and cards on the field come before cards in the hand in this). Then, the shortest combo wins with one exception: if the comparison is between a 1 card combo and a multi-card combo, the multi-card combo will instead win out if it starts with an earlier card. If in a comparison a winner is not decided by these criteria, the earlier combo wins.
  50.  
  51. (Note that due to this the only way the AI can ever do equip + monster from the hand is if the equip is before the monster, or the monster benefits from the current field.)
  52.  
  53. There are four possible outcomes of the search for the best combo play, and the AI behaves differently in each case.
  54.  
  55. If the best combo play is cards from the hand, the AI will play it in the first free monster zone.
  56.  
  57. If the best combo play is playing on top of a card on the field, it will do that play. There is one rare bug here though: if the best way is to put one magic on top of a monster (like Zanki + Warrior Elimination = Armored Zombie), then the AI will just activate the magic.
  58.  
  59. If there are no combo plays possible, the AI goes to LBL_SET_MAGIC.
  60.  
  61. Else the best combo play is doing nothing to a card on the field. Then instead the AI will try to support this card by changing the field to a type that boosts it. If the AI has the correct field spell and the field is not of the appropriate type, then the field spell is played from the hand.
  62.  
  63. For Beast-Warriors Sogen is checked before Forest, and for Thunders Mountain is checked before Umi. If the AI has the first field spell but that field is already active, the second field spell check is skipped.
  64.  
  65. Failing that the AI will look for the monster in its hand with the highest base max stat and play it in the first free monster zone.
  66.  
  67. If the AI also has no monsters in the hand, it selects a magic randomly from the first 5 cards in the hand. This is then set in the first free slot. If there are no free slots, then it does the following backup play:
  68. Magic/Ritual - activate from the hand
  69. Trap - play over random magic zone slot
  70. Equip - play over first monster that takes the equip, if there are none
  71. play over monster with lowest true max stat, and if there are no
  72. monsters at all then over random magic zone slot.
  73.  
  74. LBL_IMPROVE_MONSTER:
  75.  
  76. The AI loops over all their cards from lowest true max stat to highest (earlier cards are looked at first in case of a tie). For each one, the AI will see if it can improve the card with a combo play from the hand on top of it. The maximum length of the combo play (excluding the field card) is Max Improve Length from the spreadsheet if the number of cards in the AI's deck is more than Critical Deck Size from the spreadsheet, else it is 1.
  77.  
  78. The AI will judge how good a combo is by looking at the base max stat plus field boost of the resulting card. In case of a tie, the shortest combo play wins. In case of a tie then, the combo starting with earlier cards in the hand wins.
  79.  
  80. If the AI thinks the best combo play is not just leaving the card be, the AI will perform the combo play. Again the same rare bug can happen with a sole magic on top of a monster, as explained in the LBL_FIND_BEST_COMBO section.
  81.  
  82. If the AI thinks it is best to leave all cards on the field be, it will jump to LBL_FIND_BEST_COMBO.
  83.  
  84. LBL_SET_MAGIC:
  85.  
  86. If the AI has only monsters in their hand, they pick the one with the highest base max stat and play it in the first free monster zone.
  87.  
  88. If the AI has a non-monster in the hand, they look for the first trap. If there is none they try the first equip, then first magic, then finally first ritual. Then they will try to set it in the first free slot. If there are no free slots, then it does the following backup play:
  89. Magic/Ritual - activate from the hand
  90. Trap - play over random magic zone slot
  91. Equip - play over first monster that takes the equip, if there are none
  92. play over monster with lowest true max stat, and if there are no
  93. monsters at all then over random magic zone slot.
  94.  
  95. LBL_AI_LACKS_FIELD_CONTROL:
  96.  
  97. The AI first picks the card in its hand with the highest base max stat. If the AI has no monsters, it plays it in the first free monster zone. Else if its base max stat is greater than or equal to the player's best true max stat (out of their visible cards), the AI still plays it in the first free monster zone.
  98.  
  99. Next it turns to trying to use magics and traps to regain field control. If the AI has at least 33 cards in its deck, the AI jumps to LBL_FIND_BEST_COMBO. Otherwise it looks at spells in the following order, and activates them if the given conditions are met. The traps are instead set in the first free slot, unless there are no free slots in which case the AI places them into a random slot.
  100.  
  101. Dragon Capture Jar
  102. Type of the player's best card is Dragon.
  103.  
  104. Warrior Elimination
  105. Type of the player's best card is Warrior.
  106.  
  107. Eternal Rest
  108. Type of the player's best card is Zombie.
  109.  
  110. Stain Storm
  111. Type of the player's best card is Machine.
  112.  
  113. Eradicating Aerosol
  114. Type of the player's best card is Insect.
  115.  
  116. Breath of Light
  117. Type of the player's best card is Rock.
  118.  
  119. Eternal Draught
  120. Type of the player's best card is Fish.
  121.  
  122. Spellbinding Circle
  123. Shadow Spell
  124. No conditions.
  125.  
  126. Crush Card
  127. Player's best card's base attack plus field boost is at least 1500.
  128.  
  129. Raigeki
  130. Widespread Ruin
  131. Acid Trap Hole
  132. Invisible Wire
  133. Bear Trap
  134. Eatgaboon
  135. House of Adhesive Tape
  136. Fake Trap
  137. No conditions.
  138.  
  139. Swords of Revealing Light
  140. Player isn't already under the effect of Swords of Revealing Light.
  141.  
  142. Dark Hole
  143. Player has more monsters.
  144.  
  145. Failing all this, the AI goes to LBL_FIND_BEST_COMBO.
Add Comment
Please, Sign In to add comment