From 299358264dbaa6b3c423d671c091f8ca40b2d42a Mon Sep 17 00:00:00 2001 From: Agetian Date: Sat, 17 Jun 2017 17:31:14 +0000 Subject: [PATCH] - Since Mirror Entity Avatar is used offensively by the AI, make the conditions somewhat more restricted and dependent on the opposition to try to ensure that it doesn't fail as an attrition attack (otherwise the AI wastes all mana). --- .../java/forge/ai/ability/ChooseTypeAi.java | 25 ++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/forge-ai/src/main/java/forge/ai/ability/ChooseTypeAi.java b/forge-ai/src/main/java/forge/ai/ability/ChooseTypeAi.java index cf59cc6dc87..90c5393c998 100644 --- a/forge-ai/src/main/java/forge/ai/ability/ChooseTypeAi.java +++ b/forge-ai/src/main/java/forge/ai/ability/ChooseTypeAi.java @@ -68,6 +68,29 @@ public class ChooseTypeAi extends SpellAbilityAi { int maxX = ComputerUtilMana.determineMaxAffordableX(aiPlayer, sa); int avgPower = 0; + // predict the opposition + CardCollection oppCreatures = CardLists.filter(aiPlayer.getOpponents().getCreaturesInPlay(), CardPredicates.Presets.UNTAPPED); + int maxOppPower = 0; + int maxOppToughness = 0; + int oppUsefulCreatures = 0; + + for (Card oppCre : oppCreatures) { + if (ComputerUtilCard.isUselessCreature(aiPlayer, oppCre)) { + continue; + } + // TODO: should low-power tokens be considered here? + if (oppCre.isToken() && oppCre.getCurrentPower() < 2 && oppCre.getCurrentToughness() < 3) { + continue; + } + if (oppCre.getCurrentPower() > maxOppPower) { + maxOppPower = oppCre.getCurrentPower(); + } + if (oppCre.getCurrentToughness() > maxOppToughness) { + maxOppToughness = oppCre.getCurrentToughness(); + } + oppUsefulCreatures++; + } + if (maxX > 1) { CardCollection cre = CardLists.filter(aiPlayer.getCardsIn(ZoneType.Battlefield), Predicates.and(CardPredicates.isType(chosenType), CardPredicates.Presets.UNTAPPED)); @@ -76,7 +99,7 @@ public class ChooseTypeAi extends SpellAbilityAi { avgPower += c.getCurrentPower(); } avgPower /= cre.size(); - if (maxX > avgPower) { + if (maxX > avgPower && maxX > maxOppPower && maxX > maxOppToughness && cre.size() >= oppUsefulCreatures) { sa.setSVar("PayX", String.valueOf(maxX)); AiCardMemory.rememberCard(aiPlayer, sa.getHostCard(), AiCardMemory.MemorySet.ANIMATED_THIS_TURN); return true;