From 267c8c6b0d4e7e09225ac49843285f9075f31f65 Mon Sep 17 00:00:00 2001 From: Myrd Date: Fri, 20 Dec 2019 16:57:14 +0000 Subject: [PATCH] Avoid combat simulation if the current player has no creatures in play. --- .../main/java/forge/ai/simulation/GameStateEvaluator.java | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/forge-ai/src/main/java/forge/ai/simulation/GameStateEvaluator.java b/forge-ai/src/main/java/forge/ai/simulation/GameStateEvaluator.java index 3ee4521d4ba..f2d0f01bf85 100644 --- a/forge-ai/src/main/java/forge/ai/simulation/GameStateEvaluator.java +++ b/forge-ai/src/main/java/forge/ai/simulation/GameStateEvaluator.java @@ -29,6 +29,13 @@ public class GameStateEvaluator { if (phase.isAfter(PhaseType.COMBAT_DAMAGE) || evalGame.isGameOver()) { return null; } + // If the current player has no creatures in play, there won't be any combat. This avoids + // an expensive game copy operation. + // Note: This is is safe to do because the simulation is based on the current game state, + // so there isn't a chance to play creatures in between. + if (evalGame.getPhaseHandler().getPlayerTurn().getCreaturesInPlay().isEmpty()) { + return null; + } GameCopier copier = new GameCopier(evalGame); Game gameCopy = copier.makeCopy(); gameCopy.getPhaseHandler().devAdvanceToPhase(PhaseType.COMBAT_DAMAGE);