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 340b290b97..f086039625 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 @@ -179,10 +179,12 @@ public class ComputerPlayer6 extends ComputerPlayer implements SimulationNode2.resetCount(); root = new SimulationNode2(sim, maxDepth, playerId); logger.info("simulating actions"); + //int bestScore = addActionsTimed(new FilterAbility()); addActionsTimed(new FilterAbility()); if (root.children.size() > 0) { root = root.children.get(0); - int bestScore = GameStateEvaluator2.evaluate(playerId, root.getGame()); + //GameStateEvaluator2.evaluate(playerId, root.getGame()); + int bestScore = root.getScore(); if (bestScore > currentScore) { actions = new LinkedList(root.abilities); combat = root.combat; @@ -294,7 +296,7 @@ public class ComputerPlayer6 extends ComputerPlayer implements game.getPlayerList().setCurrent(game.getActivePlayerId()); } - protected void addActionsTimed(final FilterAbility filter) { + protected Integer addActionsTimed(final FilterAbility filter) { FutureTask task = new FutureTask(new Callable() { public Integer call() throws Exception { @@ -303,7 +305,7 @@ public class ComputerPlayer6 extends ComputerPlayer implements }); pool.execute(task); try { - task.get(Config2.maxThinkSeconds, TimeUnit.MINUTES); + return task.get(Config2.maxThinkSeconds, TimeUnit.MINUTES); } catch (TimeoutException e) { logger.info("simulating - timed out"); task.cancel(true); @@ -314,6 +316,8 @@ public class ComputerPlayer6 extends ComputerPlayer implements e.printStackTrace(); task.cancel(true); } + //TODO: timeout handling + return 0; } protected int addActions(SimulationNode2 node, FilterAbility filter, int depth, int alpha, int beta) { @@ -399,6 +403,7 @@ public class ComputerPlayer6 extends ComputerPlayer implements if (val < beta) { beta = val; bestNode = newNode; + bestNode.setScore(val); node.setCombat(newNode.getCombat()); } } @@ -406,6 +411,7 @@ public class ComputerPlayer6 extends ComputerPlayer implements if (val > alpha) { alpha = val; bestNode = newNode; + bestNode.setScore(val); node.setCombat(newNode.getCombat()); if (node.getTargets().size() > 0) targets = node.getTargets(); @@ -426,6 +432,7 @@ public class ComputerPlayer6 extends ComputerPlayer implements if (bestNode != null) { node.children.clear(); node.children.add(bestNode); + node.setScore(bestNode.getScore()); } if (!currentPlayer.getId().equals(playerId)) { //logger.info("returning priority beta: " + beta); diff --git a/Mage.Server.Plugins/Mage.Player.AI.MA/src/mage/player/ai/SimulationNode2.java b/Mage.Server.Plugins/Mage.Player.AI.MA/src/mage/player/ai/SimulationNode2.java index f32f29c0e3..7e86c59ce5 100644 --- a/Mage.Server.Plugins/Mage.Player.AI.MA/src/mage/player/ai/SimulationNode2.java +++ b/Mage.Server.Plugins/Mage.Player.AI.MA/src/mage/player/ai/SimulationNode2.java @@ -46,6 +46,7 @@ public class SimulationNode2 implements Serializable { protected Game game; protected int gameValue; + protected int score; protected List abilities; protected int depth; protected List children = new ArrayList(); @@ -124,4 +125,12 @@ public class SimulationNode2 implements Serializable { public List getChoices() { return this.choices; } + + public int getScore() { + return score; + } + + public void setScore(int score) { + this.score = score; + } } diff --git a/Mage.Tests/plugins/mage-player-ai-ma.jar b/Mage.Tests/plugins/mage-player-ai-ma.jar index 6e895cae6c..c7ee7d87e8 100644 Binary files a/Mage.Tests/plugins/mage-player-ai-ma.jar and b/Mage.Tests/plugins/mage-player-ai-ma.jar differ