mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-15 18:28:00 +00:00
- Improved Encode AI.
This commit is contained in:
@@ -35,8 +35,8 @@ public class EncodeEffect extends SpellAbilityEffect {
|
||||
choices = CardLists.getValidCards(choices, "Creature.YouCtrl", host.getController(), host);
|
||||
|
||||
// if no creatures on battlefield, cannot encoded
|
||||
if (choices.size() == 0) {
|
||||
|
||||
if (choices.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
// Handle choice of whether or not to encoded
|
||||
|
||||
@@ -46,8 +46,6 @@ public class EncodeEffect extends SpellAbilityEffect {
|
||||
if (!player.getController().confirmAction(sa, null, sb.toString())) {
|
||||
return;
|
||||
}
|
||||
// Note: AI will always choose to encode
|
||||
// TODO add better AI choice here
|
||||
|
||||
// move host card to exile
|
||||
Card movedCard = Singletons.getModel().getGame().getAction().moveTo(ZoneType.Exile, host);
|
||||
|
||||
@@ -45,6 +45,7 @@ import forge.card.spellability.SpellAbility;
|
||||
import forge.card.spellability.SpellPermanent;
|
||||
import forge.game.GameActionUtil;
|
||||
import forge.game.GameState;
|
||||
import forge.game.phase.CombatUtil;
|
||||
import forge.game.phase.PhaseType;
|
||||
import forge.game.player.AIPlayer;
|
||||
import forge.game.player.Player;
|
||||
@@ -661,20 +662,17 @@ public class AiController {
|
||||
|
||||
case Encode:
|
||||
if (logic == null) {
|
||||
// Base Logic is choose "best"
|
||||
choice = ComputerUtilCard.getBestAI(options);
|
||||
} else if ("WorstCard".equals(logic)) {
|
||||
choice = ComputerUtilCard.getWorstAI(options);
|
||||
} else if (logic.equals("BestBlocker")) {
|
||||
if (!CardLists.filter(options, Presets.UNTAPPED).isEmpty()) {
|
||||
options = CardLists.filter(options, Presets.UNTAPPED);
|
||||
List<Card> attackers = CardLists.filter(options, new Predicate<Card>() {
|
||||
@Override
|
||||
public boolean apply(final Card c) {
|
||||
return CombatUtil.canAttackNextTurn(c);
|
||||
}
|
||||
});
|
||||
if (attackers.isEmpty()) {
|
||||
choice = ComputerUtilCard.getBestAI(options);
|
||||
} else {
|
||||
choice = ComputerUtilCard.getBestAI(attackers);
|
||||
}
|
||||
choice = ComputerUtilCard.getBestCreatureAI(options);
|
||||
} else if (logic.equals("Clone")) {
|
||||
if (!CardLists.getValidCards(options, "Permanent.YouDontCtrl,Permanent.nonLegendary", host.getController(), host).isEmpty()) {
|
||||
options = CardLists.getValidCards(options, "Permanent.YouDontCtrl,Permanent.nonLegendary", host.getController(), host);
|
||||
}
|
||||
choice = ComputerUtilCard.getBestAI(options);
|
||||
}
|
||||
return choice;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user