- Improve Maze's End AI.

This commit is contained in:
Agetian
2020-06-29 22:18:05 +03:00
parent d1a63442c2
commit ad202355b2
3 changed files with 36 additions and 1 deletions

View File

@@ -756,6 +756,37 @@ public class SpecialCardAi {
}
}
// Maze's End
public static class MazesEnd {
public static boolean consider(final Player ai, final SpellAbility sa) {
PhaseHandler ph = ai.getGame().getPhaseHandler();
CardCollection availableGates = CardLists.filter(ai.getCardsIn(ZoneType.Library), CardPredicates.isType("Gate"));
return ph.is(PhaseType.END_OF_TURN) && ph.getNextTurn() == ai && !availableGates.isEmpty();
}
public static Card considerCardToGet(final Player ai, final SpellAbility sa)
{
CardCollection currentGates = CardLists.filter(ai.getCardsIn(ZoneType.Battlefield), CardPredicates.isType("Gate"));
CardCollection availableGates = CardLists.filter(ai.getCardsIn(ZoneType.Library), CardPredicates.isType("Gate"));
if (availableGates.isEmpty())
return null; // shouldn't get here
for (Card gate : availableGates)
{
if (CardLists.filter(currentGates, CardPredicates.nameEquals(gate.getName())).isEmpty())
{
// Diversify our mana base
return gate;
}
}
// Fetch a random gate if we already have all types
return Aggregates.random(availableGates);
}
}
// Mairsil, the Pretender
public static class MairsilThePretender {
// Scan the fetch list for a card with at least one activated ability.

View File

@@ -128,6 +128,8 @@ public class ChangeZoneAi extends SpellAbilityAi {
// This logic only fills the multiple cards array, the decision to play is made
// separately in hiddenOriginCanPlayAI later.
multipleCardsToChoose = SpecialCardAi.Intuition.considerMultiple(aiPlayer, sa);
} else if (aiLogic.equals("MazesEnd")) {
return SpecialCardAi.MazesEnd.consider(aiPlayer, sa);
}
}
if (isHidden(sa)) {
@@ -1491,6 +1493,8 @@ public class ChangeZoneAi extends SpellAbilityAi {
return SpecialCardAi.MairsilThePretender.considerCardFromList(fetchList);
} else if ("SurvivalOfTheFittest".equals(logic)) {
return SpecialCardAi.SurvivalOfTheFittest.considerCardToGet(decider, sa);
} else if ("MazesEnd".equals(logic)) {
return SpecialCardAi.MazesEnd.considerCardToGet(decider, sa);
} else if ("Intuition".equals(logic)) {
if (!multipleCardsToChoose.isEmpty()) {
Card choice = multipleCardsToChoose.get(0);

View File

@@ -3,7 +3,7 @@ ManaCost:no cost
Types:Land
K:CARDNAME enters the battlefield tapped.
A:AB$ Mana | Cost$ T | Produced$ C | SpellDescription$ Add {C}.
A:AB$ ChangeZone | Cost$ 3 T Return<1/CARDNAME> | ChangeType$ Gate | ChangeNum$ 1 | Origin$ Library | Destination$ Battlefield | SubAbility$ DBWin | SpellDescription$ Search your library for a Gate card, put it onto the battlefield, then shuffle your library. If you control ten or more Gates with different names, you win the game.
A:AB$ ChangeZone | Cost$ 3 T Return<1/CARDNAME> | ChangeType$ Gate | ChangeNum$ 1 | Origin$ Library | Destination$ Battlefield | AILogic$ MazesEnd | SubAbility$ DBWin | SpellDescription$ Search your library for a Gate card, put it onto the battlefield, then shuffle your library. If you control ten or more Gates with different names, you win the game.
SVar:DBWin:DB$ WinsGame | Defined$ You | ConditionCheckSVar$ MazeGate | ConditionSVarCompare$ GE10 | References$ MazeGate
SVar:MazeGate:Count$DifferentCardNames_Gate.YouCtrl+inZoneBattlefield
AI:RemoveDeck:Random