From 2b688a99ff2c9c1b853ef58a2dec4fa8a373c7fe Mon Sep 17 00:00:00 2001 From: Seravy Date: Tue, 13 Feb 2018 11:17:46 +0100 Subject: [PATCH] Improves AI logic for Hermit Druid -Will now use at end of enemy turn at 100% chance instead of wasting opportunity to get land and fill grave Not sure if "RemRandomDeck" is still needed? Card is now safe to play unless the deck has fewer than 4-5 basic lands in it. --- .../main/java/forge/ai/ability/DigUntilAi.java | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/forge-ai/src/main/java/forge/ai/ability/DigUntilAi.java b/forge-ai/src/main/java/forge/ai/ability/DigUntilAi.java index 61f7323299a..2397f6cba9d 100644 --- a/forge-ai/src/main/java/forge/ai/ability/DigUntilAi.java +++ b/forge-ai/src/main/java/forge/ai/ability/DigUntilAi.java @@ -6,6 +6,7 @@ import forge.ai.SpellAbilityAi; import forge.game.card.Card; import forge.game.card.CardLists; import forge.game.card.CardPredicates; +import forge.game.phase.PhaseType; import forge.game.player.Player; import forge.game.player.PlayerActionConfirmMode; import forge.game.spellability.AbilitySub; @@ -27,6 +28,12 @@ public class DigUntilAi extends SpellAbilityAi { chance = .667; // 66.7% chance for sorcery speed (since it will // never activate EOT) } + // if we don't use anything now, we wasted our opportunity. + if ((ai.getGame().getPhaseHandler().is(PhaseType.END_OF_TURN)) + && (!ai.getGame().getPhaseHandler().isPlayerTurn(ai))) { + chance = 1; + } + final Random r = MyRandom.getRandom(); final boolean randomReturn = r.nextFloat() <= Math.pow(chance, sa.getActivationsThisTurn() + 1); @@ -44,7 +51,13 @@ public class DigUntilAi extends SpellAbilityAi { if ("Land.Basic".equals(sa.getParam("Valid")) && !CardLists.filter(ai.getCardsIn(ZoneType.Hand), CardPredicates.Presets.LANDS_PRODUCING_MANA).isEmpty()) { // We already have a mana-producing land in hand, so bail - return false; + // until opponent's end of turn phase! + // But we still want more (and want to fill grave) if nothing better to do then + // This is important for Replenish/Living Death type decks + if (!((ai.getGame().getPhaseHandler().is(PhaseType.END_OF_TURN)) + && (!ai.getGame().getPhaseHandler().isPlayerTurn(ai)))) { + return false; + } } }