- The AI will now try to fetch duallands with fetchlands.

This commit is contained in:
Sloth
2013-03-16 13:03:52 +00:00
parent ee59663f09
commit 03d005ed8e
2 changed files with 12 additions and 8 deletions

View File

@@ -424,8 +424,7 @@ public class ChangeZoneAi extends SpellAbilityAi {
* a {@link forge.CardList} object. * a {@link forge.CardList} object.
* @return a {@link forge.Card} object. * @return a {@link forge.Card} object.
*/ */
private static Card basicManaFixing(final Player ai, final List<Card> list) { // Search for a private static Card basicManaFixing(final Player ai, final List<Card> list) { // Search for a Basic Land
// Basic Land
final List<Card> combined = new ArrayList<Card>(ai.getCardsIn(ZoneType.Battlefield)); final List<Card> combined = new ArrayList<Card>(ai.getCardsIn(ZoneType.Battlefield));
combined.addAll(ai.getCardsIn(ZoneType.Hand)); combined.addAll(ai.getCardsIn(ZoneType.Hand));
@@ -457,6 +456,11 @@ public class ChangeZoneAi extends SpellAbilityAi {
if (minType != null) { if (minType != null) {
result = CardLists.getType(list, minType); result = CardLists.getType(list, minType);
} }
// pick dual lands if available
if (Iterables.any(result, Predicates.not(CardPredicates.Presets.BASIC_LANDS))) {
result = CardLists.filter(result, Predicates.not(CardPredicates.Presets.BASIC_LANDS));
}
return result.get(0); return result.get(0);
} }
@@ -1173,7 +1177,7 @@ public class ChangeZoneAi extends SpellAbilityAi {
} else if (origin.contains(ZoneType.Library) } else if (origin.contains(ZoneType.Library)
&& (type.contains("Basic") || areAllBasics(type))) { && (type.contains("Basic") || areAllBasics(type))) {
c = basicManaFixing(ai, fetchList); c = basicManaFixing(ai, fetchList);
} else if (ZoneType.Hand.equals(destination) && CardLists.getNotType(fetchList, "Creature").size() == 0) { } else if (ZoneType.Hand.equals(destination) && CardLists.getNotType(fetchList, "Creature").isEmpty()) {
c = chooseCreature(ai, fetchList); c = chooseCreature(ai, fetchList);
} else if (ZoneType.Battlefield.equals(destination) || ZoneType.Graveyard.equals(destination)) { } else if (ZoneType.Battlefield.equals(destination) || ZoneType.Graveyard.equals(destination)) {
if (!activator.equals(ai) && sa.hasParam("GainControl")) { if (!activator.equals(ai) && sa.hasParam("GainControl")) {
@@ -1190,7 +1194,7 @@ public class ChangeZoneAi extends SpellAbilityAi {
// Does AI need a land? // Does AI need a land?
List<Card> hand = ai.getCardsIn(ZoneType.Hand); List<Card> hand = ai.getCardsIn(ZoneType.Hand);
if (CardLists.filter(hand, Presets.LANDS).size() == 0 && CardLists.filter(ai.getCardsIn(ZoneType.Battlefield), Presets.LANDS).size() < 4) { if (CardLists.filter(hand, Presets.LANDS).isEmpty() && CardLists.filter(ai.getCardsIn(ZoneType.Battlefield), Presets.LANDS).size() < 4) {
boolean canCastSomething = false; boolean canCastSomething = false;
for (Card cardInHand : hand) { for (Card cardInHand : hand) {
canCastSomething |= ComputerUtilMana.payManaCost(cardInHand.getFirstSpellAbility(), ai, true, 0, false); canCastSomething |= ComputerUtilMana.payManaCost(cardInHand.getFirstSpellAbility(), ai, true, 0, false);

View File

@@ -124,14 +124,14 @@ public class ComputerUtilCard {
*/ */
public static Card getBestLandAI(final List<Card> list) { public static Card getBestLandAI(final List<Card> list) {
final List<Card> land = CardLists.filter(list, CardPredicates.Presets.LANDS); final List<Card> land = CardLists.filter(list, CardPredicates.Presets.LANDS);
if (!(land.size() > 0)) { if (land.isEmpty()) {
return null; return null;
} }
// prefer to target non basic lands // prefer to target non basic lands
final List<Card> nbLand = CardLists.filter(land, Predicates.not(CardPredicates.Presets.BASIC_LANDS)); final List<Card> nbLand = CardLists.filter(land, Predicates.not(CardPredicates.Presets.BASIC_LANDS));
if (nbLand.size() > 0) { if (!nbLand.isEmpty()) {
// TODO - Rank non basics? // TODO - Rank non basics?
return Aggregates.random(nbLand); return Aggregates.random(nbLand);
} }
@@ -243,11 +243,11 @@ public class ComputerUtilCard {
public static Card getBestAI(final List<Card> list) { public static Card getBestAI(final List<Card> list) {
// Get Best will filter by appropriate getBest list if ALL of the list // Get Best will filter by appropriate getBest list if ALL of the list
// is of that type // is of that type
if (CardLists.getNotType(list, "Creature").size() == 0) { if (CardLists.getNotType(list, "Creature").isEmpty()) {
return ComputerUtilCard.getBestCreatureAI(list); return ComputerUtilCard.getBestCreatureAI(list);
} }
if (CardLists.getNotType(list, "Land").size() == 0) { if (CardLists.getNotType(list, "Land").isEmpty()) {
return getBestLandAI(list); return getBestLandAI(list);
} }