From 424ecde6e34541bea15ec651ca1537e32fe387fd Mon Sep 17 00:00:00 2001 From: magenoxx Date: Sat, 12 Feb 2011 11:48:01 +0300 Subject: [PATCH] Previous comment wasn't full: added error handling. Fixed PlayerImpl, added work around to BoostPowerXSourceEffect. Fixed some bugs in AI. --- .../src/mage/player/ai/ComputerPlayer4.java | 6 +++--- .../src/mage/player/ai/ComputerPlayer5.java | 15 +++++++++------ 2 files changed, 12 insertions(+), 9 deletions(-) diff --git a/Mage.Server.Plugins/Mage.Player.AI.MA/src/mage/player/ai/ComputerPlayer4.java b/Mage.Server.Plugins/Mage.Player.AI.MA/src/mage/player/ai/ComputerPlayer4.java index a4a99e6819..8e606aed33 100644 --- a/Mage.Server.Plugins/Mage.Player.AI.MA/src/mage/player/ai/ComputerPlayer4.java +++ b/Mage.Server.Plugins/Mage.Player.AI.MA/src/mage/player/ai/ComputerPlayer4.java @@ -299,14 +299,14 @@ public class ComputerPlayer4 extends ComputerPlayer implements }); pool.execute(task); try { - task.get(Config2.maxThinkSeconds, TimeUnit.SECONDS); + task.get(Config2.maxThinkSeconds, TimeUnit.MINUTES); } catch (TimeoutException e) { logger.info("simulating - timed out"); task.cancel(true); } catch (ExecutionException e) { - + e.printStackTrace(); } catch (InterruptedException e) { - + e.printStackTrace(); } } diff --git a/Mage.Server.Plugins/Mage.Player.AI.MA/src/mage/player/ai/ComputerPlayer5.java b/Mage.Server.Plugins/Mage.Player.AI.MA/src/mage/player/ai/ComputerPlayer5.java index cff09a4683..9ab60808bd 100644 --- a/Mage.Server.Plugins/Mage.Player.AI.MA/src/mage/player/ai/ComputerPlayer5.java +++ b/Mage.Server.Plugins/Mage.Player.AI.MA/src/mage/player/ai/ComputerPlayer5.java @@ -171,7 +171,7 @@ public class ComputerPlayer5 extends ComputerPlayer4 implements Player { } protected void calculatePreCombatActions(Game game) { - if (!getNextAction(game)) { + //if (!getNextAction(game)) { currentScore = GameStateEvaluator2.evaluate(playerId, game); Game sim = createSimulation(game); SimulationNode2.resetCount(); @@ -184,7 +184,7 @@ public class ComputerPlayer5 extends ComputerPlayer4 implements Player { actions = new LinkedList(root.abilities); combat = root.combat; } - } + //} } protected void calculatePostCombatActions(Game game) { @@ -406,11 +406,14 @@ public class ComputerPlayer5 extends ComputerPlayer4 implements Player { break; } Game sim = game.copy(); - for (CombatGroup group: engagement.getGroups()) { - UUID attackerId = group.getAttackers().get(0); - for (UUID blockerId: group.getBlockers()) { - sim.getPlayer(defenderId).declareBlocker(blockerId, attackerId, sim); + for (CombatGroup group : engagement.getGroups()) { + if (group.getAttackers().size() > 0) { + UUID attackerId = group.getAttackers().get(0); + for (UUID blockerId : group.getBlockers()) { + sim.getPlayer(defenderId).declareBlocker(blockerId, attackerId, sim); + } } + } sim.fireEvent(GameEvent.getEvent(GameEvent.EventType.DECLARED_BLOCKERS, playerId, playerId)); SimulationNode2 newNode = new SimulationNode2(sim, depth, defenderId);