diff --git a/Mage.Client/plugins/mage-player-ai-ma.jar b/Mage.Client/plugins/mage-player-ai-ma.jar index 914adf8edd..b9167bd50b 100644 Binary files a/Mage.Client/plugins/mage-player-ai-ma.jar and b/Mage.Client/plugins/mage-player-ai-ma.jar differ diff --git a/Mage.Server.Plugins/Mage.Player.AI.MA/src/mage/player/ai/ComputerPlayer6.java b/Mage.Server.Plugins/Mage.Player.AI.MA/src/mage/player/ai/ComputerPlayer6.java index 542da99f92..8f1ea13e41 100644 --- a/Mage.Server.Plugins/Mage.Player.AI.MA/src/mage/player/ai/ComputerPlayer6.java +++ b/Mage.Server.Plugins/Mage.Player.AI.MA/src/mage/player/ai/ComputerPlayer6.java @@ -503,7 +503,9 @@ public class ComputerPlayer6 extends ComputerPlayer implements beta = val; bestNode = newNode; bestNode.setScore(val); - node.setCombat(newNode.getCombat()); + if (newNode.getChildren().size() > 0) { + bestNode.setCombat(newNode.getChildren().get(0).getCombat()); + } } // no need to check other actions @@ -517,11 +519,14 @@ public class ComputerPlayer6 extends ComputerPlayer implements alpha = val; bestNode = newNode; bestNode.setScore(val); - node.setCombat(newNode.getCombat()); - if (node.getTargets().size() > 0) + if (newNode.getChildren().size() > 0) { + bestNode.setCombat(newNode.getChildren().get(0).getCombat()); + } + /*if (node.getTargets().size() > 0) targets = node.getTargets(); if (node.getChoices().size() > 0) choices = node.getChoices(); + */ if (depth == maxDepth) { logger.info("saved"); node.children.clear(); @@ -813,6 +818,7 @@ public class ComputerPlayer6 extends ComputerPlayer implements for (int i = 0; i < groups.size(); i++) { if (i < combat.getGroups().size()) { for (UUID blockerId: combat.getGroups().get(i).getBlockers()) { + logger.info("select blocker: " + blockerId + " vs " + groups.get(i).getAttackers().get(0)); this.declareBlocker(blockerId, groups.get(i).getAttackers().get(0), game); } } diff --git a/Mage.Server.Plugins/Mage.Player.AI.MA/src/mage/player/ai/ComputerPlayer7.java b/Mage.Server.Plugins/Mage.Player.AI.MA/src/mage/player/ai/ComputerPlayer7.java index 494b330666..b85e1cd23c 100644 --- a/Mage.Server.Plugins/Mage.Player.AI.MA/src/mage/player/ai/ComputerPlayer7.java +++ b/Mage.Server.Plugins/Mage.Player.AI.MA/src/mage/player/ai/ComputerPlayer7.java @@ -43,6 +43,7 @@ import mage.players.Player; import org.apache.log4j.Logger; import java.util.LinkedList; +import java.util.List; import java.util.UUID; /** @@ -184,6 +185,7 @@ public class ComputerPlayer7 extends ComputerPlayer6 implements Player { //if (bestScore > currentScore || allowBadMoves) { actions = new LinkedList(root.abilities); combat = root.combat; + logger.debug("final score: " + bestScore); //} else { //System.out.println("[" + game.getPlayer(playerId).getName() + "][post] Action: not better score"); //} @@ -241,8 +243,8 @@ public class ComputerPlayer7 extends ComputerPlayer6 implements Player { val = simulateCombat(game, node, depth-1, alpha, beta, false); break; case POSTCOMBAT_MAIN: - val = simulateCounterAttack(game, node, depth-1, alpha, beta); - break; + //val = simulateCounterAttack(game, node, depth-1, alpha, beta); + //break; default: val = GameStateEvaluator2.evaluate(playerId, game); break; @@ -305,7 +307,7 @@ public class ComputerPlayer7 extends ComputerPlayer6 implements Player { } else if (!counter) { finishCombat(game); - val = simulateCounterAttack(game, node, depth, alpha, beta); + ///val = simulateCounterAttack(game, node, depth, alpha, beta); } } if (val == null) @@ -329,6 +331,9 @@ public class ComputerPlayer7 extends ComputerPlayer6 implements Player { if (logger.isDebugEnabled()) logger.debug(attacker.getName() + "'s possible attackers: " + attacker.getAvailableAttackers(game)); for (Combat engagement: attacker.addAttackers(game)) { + if (logger.isDebugEnabled()) { + logger.debug("Attackers: " + engagement.getAttackers() + ", blockers: " + engagement.getBlockers()); + } if (alpha >= beta) { logger.debug("simulating -- pruning attackers"); break; @@ -359,7 +364,9 @@ public class ComputerPlayer7 extends ComputerPlayer6 implements Player { beta = val; bestNode = newNode; bestNode.setScore(val); - node.setCombat(simCombat); + if (newNode.getChildren().size() > 0) { + bestNode.setCombat(newNode.getChildren().get(0).getCombat()); + } } } else { @@ -367,7 +374,9 @@ public class ComputerPlayer7 extends ComputerPlayer6 implements Player { alpha = val; bestNode = newNode; bestNode.setScore(val); - node.setCombat(simCombat); + if (newNode.getChildren().size() > 0) { + bestNode.setCombat(newNode.getChildren().get(0).getCombat()); + } } } } @@ -396,7 +405,8 @@ public class ComputerPlayer7 extends ComputerPlayer6 implements Player { SimulatedPlayer2 defender = (SimulatedPlayer2) game.getPlayer(defenderId); if (logger.isDebugEnabled()) logger.debug(defender.getName() + "'s possible blockers: " + defender.getAvailableBlockers(game)); - for (Combat engagement: defender.addBlockers(game)) { + List combats = defender.addBlockers(game); + for (Combat engagement: combats) { if (alpha >= beta) { logger.debug("simulating -- pruning blockers"); break; @@ -436,14 +446,15 @@ public class ComputerPlayer7 extends ComputerPlayer6 implements Player { beta = val; bestNode = newNode; bestNode.setScore(val); - node.setCombat(simCombat); + bestNode.setCombat(simCombat); } } else { if (val > alpha) { alpha = val; bestNode = newNode; - node.setCombat(simCombat); + bestNode.setScore(val); + bestNode.setCombat(simCombat); } } } @@ -532,7 +543,8 @@ public class ComputerPlayer7 extends ComputerPlayer6 implements Player { game.getPlayers().resetPassed(); return addActions(node, depth, alpha, beta); } - return simulateCounterAttack(game, node, depth, alpha, beta); + //return simulateCounterAttack(game, node, depth, alpha, beta); + return GameStateEvaluator2.evaluate(playerId, game); } protected void simulateToEnd(Game game) { diff --git a/Mage.Server.Plugins/Mage.Player.AI.MA/src/mage/player/ai/GameStateEvaluator2.java b/Mage.Server.Plugins/Mage.Player.AI.MA/src/mage/player/ai/GameStateEvaluator2.java index 3aa0a88949..05c05245d1 100644 --- a/Mage.Server.Plugins/Mage.Player.AI.MA/src/mage/player/ai/GameStateEvaluator2.java +++ b/Mage.Server.Plugins/Mage.Player.AI.MA/src/mage/player/ai/GameStateEvaluator2.java @@ -5,16 +5,16 @@ package mage.player.ai; -import java.util.UUID; -import java.util.logging.Level; -import java.util.logging.Logger; - import mage.game.Game; import mage.game.permanent.Permanent; import mage.player.ai.ma.ArtificialScoringSystem; import mage.players.Player; import mage.util.Logging; +import java.util.UUID; +import java.util.logging.Level; +import java.util.logging.Logger; + /** * * @author nantuko @@ -80,7 +80,7 @@ public class GameStateEvaluator2 { int score = lifeScore + permanentScore + handScore; //if (logger.isLoggable(Level.FINE)) logger.fine("game state evaluated to- lifeScore:" + lifeScore + " permanentScore:" + permanentScore /*+ " handScore:" + handScore*/ + "total:" + score); - return score; + return score; } public static int evaluatePermanent(Permanent permanent, Game game) { diff --git a/Mage.Server.Plugins/Mage.Player.AI.MA/src/mage/player/ai/SimulatedPlayer2.java b/Mage.Server.Plugins/Mage.Player.AI.MA/src/mage/player/ai/SimulatedPlayer2.java index 4880ac6591..fa799bbe82 100644 --- a/Mage.Server.Plugins/Mage.Player.AI.MA/src/mage/player/ai/SimulatedPlayer2.java +++ b/Mage.Server.Plugins/Mage.Player.AI.MA/src/mage/player/ai/SimulatedPlayer2.java @@ -272,7 +272,14 @@ public class SimulatedPlayer2 extends ComputerPlayer { logger.debug("simulating -- attack:" + sim.getCombat().getGroups().size()); } } - return new ArrayList(engagements.values()); + List list = new ArrayList(engagements.values()); + Collections.sort(list, new Comparator() { + @Override + public int compare(Combat o1, Combat o2) { + return Integer.valueOf(o2.getGroups().size()).compareTo(Integer.valueOf(o1.getGroups().size())); + } + }); + return list; } public List addBlockers(Game game) { diff --git a/Mage.Server/plugins/mage-player-ai-ma.jar b/Mage.Server/plugins/mage-player-ai-ma.jar index 914adf8edd..b9167bd50b 100644 Binary files a/Mage.Server/plugins/mage-player-ai-ma.jar and b/Mage.Server/plugins/mage-player-ai-ma.jar differ diff --git a/Mage.Tests/plugins/mage-deck-constructed.jar b/Mage.Tests/plugins/mage-deck-constructed.jar index cc3735cc5b..8dc0f0de54 100644 Binary files a/Mage.Tests/plugins/mage-deck-constructed.jar and b/Mage.Tests/plugins/mage-deck-constructed.jar differ diff --git a/Mage.Tests/plugins/mage-deck-limited.jar b/Mage.Tests/plugins/mage-deck-limited.jar index 05df1d848a..6b6a5ef830 100644 Binary files a/Mage.Tests/plugins/mage-deck-limited.jar and b/Mage.Tests/plugins/mage-deck-limited.jar differ diff --git a/Mage.Tests/plugins/mage-game-twoplayerduel.jar b/Mage.Tests/plugins/mage-game-twoplayerduel.jar index 48664d55c3..bed9f04322 100644 Binary files a/Mage.Tests/plugins/mage-game-twoplayerduel.jar and b/Mage.Tests/plugins/mage-game-twoplayerduel.jar differ diff --git a/Mage.Tests/plugins/mage-player-ai-ma.jar b/Mage.Tests/plugins/mage-player-ai-ma.jar index 914adf8edd..b9167bd50b 100644 Binary files a/Mage.Tests/plugins/mage-player-ai-ma.jar and b/Mage.Tests/plugins/mage-player-ai-ma.jar differ diff --git a/Mage.Tests/src/test/java/org/mage/test/ai/LevelUpAbilityTest.java b/Mage.Tests/src/test/java/org/mage/test/ai/LevelUpAbilityTest.java index 42c6c78913..190a1af80b 100644 --- a/Mage.Tests/src/test/java/org/mage/test/ai/LevelUpAbilityTest.java +++ b/Mage.Tests/src/test/java/org/mage/test/ai/LevelUpAbilityTest.java @@ -4,7 +4,6 @@ import junit.framework.Assert; import mage.Constants; import mage.counters.Counter; import mage.counters.CounterType; -import mage.game.GameImpl; import mage.game.permanent.Permanent; import org.junit.Test; import org.mage.test.serverside.base.CardTestBase; @@ -37,8 +36,5 @@ public class LevelUpAbilityTest extends CardTestBase { Assert.assertNotNull(master.getCounters()); Assert.assertFalse(master.getCounters().isEmpty()); Assert.assertEquals(12, master.getCounters().getCount(CounterType.LEVEL)); - - System.out.println("Copy count: " + GameImpl.copyCount); - System.out.println("Copy time: " + GameImpl.copyTime + " ms"); } } diff --git a/Mage.Tests/src/test/java/org/mage/test/combat/DamageDistributionTest.java b/Mage.Tests/src/test/java/org/mage/test/combat/DamageDistributionTest.java index 145b6d71ed..1874c8f9ce 100644 --- a/Mage.Tests/src/test/java/org/mage/test/combat/DamageDistributionTest.java +++ b/Mage.Tests/src/test/java/org/mage/test/combat/DamageDistributionTest.java @@ -22,6 +22,7 @@ public class DamageDistributionTest extends CardTestBase { Permanent instigator = getPermanent("Warren Instigator", playerA.getId()); Assert.assertNotNull(instigator); + Assert.assertTrue("Computer didn't attacked with Warren Instigator", instigator.isTapped()); // should block and die assertPermanentCount(playerB, "Merfolk Looter", 0); diff --git a/Mage.Tests/src/test/java/org/mage/test/serverside/performance/CopyGameStatePerformanceTest.java b/Mage.Tests/src/test/java/org/mage/test/serverside/performance/CopyGameStatePerformanceTest.java index d92775c466..82641d5c21 100644 --- a/Mage.Tests/src/test/java/org/mage/test/serverside/performance/CopyGameStatePerformanceTest.java +++ b/Mage.Tests/src/test/java/org/mage/test/serverside/performance/CopyGameStatePerformanceTest.java @@ -1,6 +1,7 @@ package org.mage.test.serverside.performance; import mage.game.Game; +import org.junit.Ignore; import org.mage.test.serverside.base.CardTestBase; /** @@ -8,6 +9,7 @@ import org.mage.test.serverside.base.CardTestBase; * * @ayratn */ +@Ignore public class CopyGameStatePerformanceTest extends CardTestBase { public void run() throws Exception {