- Improved AI chosing lands to play.

This commit is contained in:
Sloth
2015-09-29 09:20:42 +00:00
parent 1f53269cd9
commit e0956ff9bd

View File

@@ -445,29 +445,38 @@ public class AiController {
unreflectedLands.remove(l); unreflectedLands.remove(l);
} }
} }
if (!unreflectedLands.isEmpty()) { if (!unreflectedLands.isEmpty()) {
landList = unreflectedLands; landList = unreflectedLands;
} }
// Choose first land to be able to play a one drop CardCollection nonLandsInHand = CardLists.filter(player.getCardsIn(ZoneType.Hand), Predicates.not(CardPredicates.Presets.LANDS));
if (player.getLandsInPlay().isEmpty()) {
CardCollection oneDrops = CardLists.filter(player.getCardsIn(ZoneType.Hand), CardPredicates.hasCMC(1)); //try to skip lands that enter the battlefield tapped
for (int i = 0; i < MagicColor.WUBRG.length; i++) { if (!nonLandsInHand.isEmpty()) {
byte color = MagicColor.WUBRG[i]; CardCollection nonTappeddLands = new CardCollection(landList);
if (!CardLists.filter(oneDrops, CardPredicates.isColor(color)).isEmpty()) {
for (Card land : landList) { for (Card land : landList) {
// Don't play ETB Tapped land if you have a 1 drop can be played
// Is this the best way to check if a land ETB Tapped? // Is this the best way to check if a land ETB Tapped?
if (land.hasSVar("ETBTappedSVar")) { if (land.hasSVar("ETBTappedSVar")) {
continue; continue;
} }
// Glacial Fortress and friends // Glacial Fortress and friends
if (land.hasSVar("ETBCheckSVar")) { if (land.hasSVar("ETBCheckSVar") && CardFactoryUtil.xCount(land, land.getSVar("ETBCheckSVar")) == 0) {
continue; continue;
} }
nonTappeddLands.add(land);
}
if (!nonTappeddLands.isEmpty()) {
landList = nonTappeddLands;
}
}
// Choose first land to be able to play a one drop
if (player.getLandsInPlay().isEmpty()) {
CardCollection oneDrops = CardLists.filter(nonLandsInHand, CardPredicates.hasCMC(1));
for (int i = 0; i < MagicColor.WUBRG.length; i++) {
byte color = MagicColor.WUBRG[i];
if (!CardLists.filter(oneDrops, CardPredicates.isColor(color)).isEmpty()) {
for (Card land : landList) {
if (land.getType().hasSubtype(MagicColor.Constant.BASIC_LANDS.get(i))) { if (land.getType().hasSubtype(MagicColor.Constant.BASIC_LANDS.get(i))) {
return land; return land;
} }