From e470cf95e3850f8f7c25e06740d3237b692527e3 Mon Sep 17 00:00:00 2001 From: Sloth Date: Tue, 21 May 2013 11:46:10 +0000 Subject: [PATCH] - Fixed AI using a card to pay for its own ability. --- src/main/java/forge/game/ai/ComputerUtilMana.java | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/src/main/java/forge/game/ai/ComputerUtilMana.java b/src/main/java/forge/game/ai/ComputerUtilMana.java index e9ca9e8c092..aa4e93b810e 100644 --- a/src/main/java/forge/game/ai/ComputerUtilMana.java +++ b/src/main/java/forge/game/ai/ComputerUtilMana.java @@ -105,7 +105,10 @@ public class ComputerUtilMana { Map> sourcesForShards = ComputerUtilMana.groupAndOrderToPayShards(ai, manaAbilityMap, cost); // Loop over mana needed - List cardsUsed = test ? new ArrayList() : null; + List cardsUsed = new ArrayList(); + + //don't use a card to pay for itself - miscalculations! + cardsUsed.add(sa.getSourceCard()); ManaCostShard toPay = null; while (!cost.isPaid()) { @@ -415,6 +418,8 @@ public class ComputerUtilMana { if (cost.getColorlessManaAmount() > 0 && manaAbilityMap.containsKey(ManaAtom.COLORLESS)) res.addAll(ManaCostShard.COLORLESS, manaAbilityMap.get(ManaAtom.COLORLESS)); + + System.out.println("groupAndOrderToPayShards " + res); return res; } @@ -465,7 +470,7 @@ public class ComputerUtilMana { return cost; } - //This method is currently used by AI to estimate human's available mana + //This method is currently used by AI to estimate available mana public static List getAvailableMana(final Player ai, final boolean checkPlayable) { final List list = ai.getCardsIn(ZoneType.Battlefield); list.addAll(ai.getCardsIn(ZoneType.Hand)); @@ -573,11 +578,12 @@ public class ComputerUtilMana { CardLists.sortByEvaluateCreature(otherManaSources); Collections.reverse(otherManaSources); sortedManaSources.addAll(otherManaSources); + System.out.println("getAvailableMana " + sortedManaSources); return sortedManaSources; } // getAvailableMana() - //This method is currently used by AI to estimate mana available to human + //This method is currently used by AI to estimate mana available private static MapOfLists groupSourcesByManaColor(final Player ai, boolean checkPlayable) { final MapOfLists manaMap = new TreeMapOfLists(CollectionSuppliers.arrayLists()); @@ -622,6 +628,7 @@ public class ComputerUtilMana { } // end of mana abilities loop } // end of mana sources loop + System.out.println("groupSourcesByManaColor " + manaMap); return manaMap; }