diff --git a/Mage.Server.Plugins/Mage.Player.AIMinimax/src/mage/player/ai/ComputerPlayer2.java b/Mage.Server.Plugins/Mage.Player.AIMinimax/src/mage/player/ai/ComputerPlayer2.java index 641079d53c..b5e0f68f5a 100644 --- a/Mage.Server.Plugins/Mage.Player.AIMinimax/src/mage/player/ai/ComputerPlayer2.java +++ b/Mage.Server.Plugins/Mage.Player.AIMinimax/src/mage/player/ai/ComputerPlayer2.java @@ -394,6 +394,11 @@ public class ComputerPlayer2 extends ComputerPlayer implements if (logger.isDebugEnabled()) logger.debug("simulating -- adding " + allActions.size() + " children:" + allActions); for (Ability action: allActions) { + if (Thread.interrupted()) { + Thread.currentThread().interrupt(); + logger.debug("interrupted"); + break; + } Game sim = game.copy(); if (sim.getPlayer(currentPlayer.getId()).activateAbility((ActivatedAbility) action.copy(), sim)) { sim.applyEffects(); diff --git a/Mage.Server/plugins/mage-player-aiminimax.jar b/Mage.Server/plugins/mage-player-aiminimax.jar index e14b772836..e72f7fc423 100644 Binary files a/Mage.Server/plugins/mage-player-aiminimax.jar and b/Mage.Server/plugins/mage-player-aiminimax.jar differ diff --git a/Mage.Tests/plugins/mage-player-aiminimax.jar b/Mage.Tests/plugins/mage-player-aiminimax.jar index d7c8a7a2e1..e72f7fc423 100644 Binary files a/Mage.Tests/plugins/mage-player-aiminimax.jar and b/Mage.Tests/plugins/mage-player-aiminimax.jar differ diff --git a/Mage.Tests/src/test/java/org/mage/test/serverside/PlayGameTest.java b/Mage.Tests/src/test/java/org/mage/test/serverside/PlayGameTest.java index d8e2df7e79..4f1fcfb776 100644 --- a/Mage.Tests/src/test/java/org/mage/test/serverside/PlayGameTest.java +++ b/Mage.Tests/src/test/java/org/mage/test/serverside/PlayGameTest.java @@ -2,14 +2,11 @@ package org.mage.test.serverside; import mage.Constants; import mage.cards.Card; -import mage.cards.ExpansionSet; import mage.cards.decks.Deck; import mage.game.Game; import mage.game.GameException; import mage.game.TwoPlayerDuel; -import mage.game.permanent.Permanent; import mage.game.permanent.PermanentCard; -import mage.game.permanent.PermanentImpl; import mage.players.Player; import mage.server.game.PlayerFactory; import mage.sets.Sets; @@ -28,8 +25,8 @@ public class PlayGameTest extends MageTestBase { private List handCardsA = new ArrayList(); private List handCardsB = new ArrayList(); - private List battlefieldCardsA = new ArrayList(); - private List battlefieldCardsB = new ArrayList(); + private List battlefieldCardsA = new ArrayList(); + private List battlefieldCardsB = new ArrayList(); private List graveyardCardsA = new ArrayList(); private List graveyardCardsB = new ArrayList(); private List libraryCardsA = new ArrayList(); @@ -42,8 +39,8 @@ public class PlayGameTest extends MageTestBase { public void playOneGame() throws GameException, FileNotFoundException, IllegalArgumentException { Game game = new TwoPlayerDuel(Constants.MultiplayerAttackOption.LEFT, Constants.RangeOfInfluence.ALL); - //Player computerA = createPlayer("ComputerA", "Computer - minimax hybrid"); - Player computerA = createPlayer("ComputerA", "Computer - mad"); + Player computerA = createPlayer("ComputerA", "Computer - minimax hybrid"); +// Player computerA = createPlayer("ComputerA", "Computer - mad"); Deck deck = Deck.load(Sets.loadDeck("RB Aggro.dck")); if (deck.getCards().size() < 40) { @@ -52,8 +49,8 @@ public class PlayGameTest extends MageTestBase { game.addPlayer(computerA, deck); game.loadCards(deck.getCards(), computerA.getId()); - //Player computerB = createPlayer("ComputerB", "Computer - minimax hybrid"); - Player computerB = createPlayer("ComputerB", "Computer - mad"); + Player computerB = createPlayer("ComputerB", "Computer - minimax hybrid"); +// Player computerB = createPlayer("ComputerB", "Computer - mad"); Deck deck2 = Deck.load(Sets.loadDeck("RB Aggro.dck")); if (deck2.getCards().size() < 40) { throw new IllegalArgumentException("Couldn't load deck, deck size=" + deck2.getCards().size()); @@ -61,7 +58,7 @@ public class PlayGameTest extends MageTestBase { game.addPlayer(computerB, deck2); game.loadCards(deck2.getCards(), computerB.getId()); - parseScenario("tests/Burn the Impure.test"); + parseScenario("scenario8.txt"); game.cheat(computerA.getId(), commandsA); game.cheat(computerA.getId(), libraryCardsA, handCardsA, battlefieldCardsA, graveyardCardsA); game.cheat(computerB.getId(), commandsB); @@ -105,14 +102,15 @@ public class PlayGameTest extends MageTestBase { String nickname = m.group(2); if (nickname.equals("ComputerA") || nickname.equals("ComputerB")) { - List cards; + List cards = null; + List perms = null; Constants.Zone gameZone; if ("hand".equalsIgnoreCase(zone)) { gameZone = Constants.Zone.HAND; cards = nickname.equals("ComputerA") ? handCardsA : handCardsB; } else if ("battlefield".equalsIgnoreCase(zone)) { gameZone = Constants.Zone.BATTLEFIELD; - cards = nickname.equals("ComputerA") ? battlefieldCardsA : battlefieldCardsB; + perms = nickname.equals("ComputerA") ? battlefieldCardsA : battlefieldCardsB; } else if ("graveyard".equalsIgnoreCase(zone)) { gameZone = Constants.Zone.GRAVEYARD; cards = nickname.equals("ComputerA") ? graveyardCardsA : graveyardCardsB; @@ -150,7 +148,7 @@ public class PlayGameTest extends MageTestBase { if (gameZone.equals(Constants.Zone.BATTLEFIELD)) { PermanentCard p = new PermanentCard(card, null); p.setTapped(tapped); - cards.add(p); + perms.add(p); } else { cards.add(card); } diff --git a/Mage.Tests/src/test/resources/log4j.properties b/Mage.Tests/src/test/resources/log4j.properties index 4e87c90cf2..605efa2a5e 100644 --- a/Mage.Tests/src/test/resources/log4j.properties +++ b/Mage.Tests/src/test/resources/log4j.properties @@ -1,11 +1,11 @@ #default levels -log4j.rootLogger=info, console, file, watchdog +log4j.rootLogger=debug, console, file, watchdog #console log log4j.appender.console=org.apache.log4j.ConsoleAppender log4j.appender.console.layout=org.apache.log4j.PatternLayout log4j.appender.console.layout.ConversionPattern=%-5p [%d{yyyy-MM-dd HH:mm [ss:SSS]}] %C{1}[%t]: %m%n -log4j.appender.console.Threshold=INFO +log4j.appender.console.Threshold=DEBUG #file log log4j.appender.file=org.apache.log4j.FileAppender diff --git a/Mage/src/mage/game/Game.java b/Mage/src/mage/game/Game.java index b0b18e30d3..147e876934 100644 --- a/Mage/src/mage/game/Game.java +++ b/Mage/src/mage/game/Game.java @@ -57,6 +57,7 @@ import mage.game.events.Listener; import mage.game.events.PlayerQueryEvent; import mage.game.permanent.Battlefield; import mage.game.permanent.Permanent; +import mage.game.permanent.PermanentCard; import mage.game.turn.Phase; import mage.game.turn.Step; import mage.game.turn.Turn; @@ -159,5 +160,5 @@ public interface Game extends MageItem, Serializable { // game cheats (for tests only) public void cheat(UUID ownerId, Map commands); - public void cheat(UUID ownerId, List library, List hand, List battlefield, List graveyard); + public void cheat(UUID ownerId, List library, List hand, List battlefield, List graveyard); } diff --git a/Mage/src/mage/game/GameImpl.java b/Mage/src/mage/game/GameImpl.java index 1e841bbc0f..b0ba80c387 100644 --- a/Mage/src/mage/game/GameImpl.java +++ b/Mage/src/mage/game/GameImpl.java @@ -911,6 +911,7 @@ public abstract class GameImpl> implements Game, Serializa * @param zone * @return */ + @Override public Card getLastKnownInformation(UUID objectId, Zone zone) { return lki.get(objectId); } @@ -922,6 +923,7 @@ public abstract class GameImpl> implements Game, Serializa * @param zone * @param card */ + @Override public void rememberLKI(UUID objectId, Zone zone, Card card) { Card copy = card.copy(); lki.put(objectId, copy); @@ -930,10 +932,12 @@ public abstract class GameImpl> implements Game, Serializa /** * Reset objects stored for Last Known Information. */ + @Override public void resetLKI() { lki.clear(); } + @Override public void cheat(UUID ownerId, Map commands) { if (commands != null) { Player player = getPlayer(ownerId); @@ -982,7 +986,8 @@ public abstract class GameImpl> implements Game, Serializa cards.clear(); } - public void cheat(UUID ownerId, List library, List hand, List battlefield, List graveyard) { + @Override + public void cheat(UUID ownerId, List library, List hand, List battlefield, List graveyard) { Player player = getPlayer(ownerId); if (player != null) { loadCards(ownerId, library); @@ -1002,23 +1007,21 @@ public abstract class GameImpl> implements Game, Serializa setZone(card.getId(), Zone.GRAVEYARD); player.getGraveyard().add(card); } - for (Card card : battlefield) { + for (PermanentCard card : battlefield) { card.setOwnerId(ownerId); PermanentCard permanent = new PermanentCard(card, ownerId); + permanent.setTapped(card.isTapped()); getBattlefield().addPermanent(permanent); } applyEffects(); } } - private void loadCards(UUID ownerId, List cards) { + private void loadCards(UUID ownerId, List cards) { if (cards == null) { return; } - Set set = new HashSet(); - for (Card card : cards) { - set.add(card); - } + Set set = new HashSet(cards); loadCards(set, ownerId); }