}
}
protected int addActions(SimulationNode node, FilterAbility filter, int depth, int alpha, int beta) {
Game game = node.getGame();
int val;
if (Thread.interrupted()) {
Thread.currentThread().interrupt();
logger.fine("interrupted");
return GameStateEvaluator.evaluate(playerId, game);
}
if (depth <= 0 || SimulationNode.nodeCount > maxNodes || game.isGameOver()) {
logger.fine("simulating -- reached end state");
val = GameStateEvaluator.evaluate(playerId, game);
}
else if (node.getChildren().size() > 0) {
logger.fine("simulating -- somthing added children:" + node.getChildren().size());
val = minimaxAB(node, filter, depth-1, alpha, beta);
}
else {
if (logger.isLoggable(Level.FINE))
logger.fine("simulating -- alpha: " + alpha + " beta: " + beta + " depth:" + depth + " step:" + game.getTurn().getStepType() + " for player:" + (node.getPlayerId().equals(playerId)?"yes":"no"));
if (allPassed(game)) {
if (!game.getStack().isEmpty()) {
resolve(node, depth, game);
}
else {
// int testScore = GameStateEvaluator.evaluate(playerId, game);
// if (testScore < currentScore) {
// // if score at end of step is worse than original score don't check any further
// logger.fine("simulating -- abandoning current check, no immediate benefit");
// return testScore;
// }
game.getPlayers().resetPassed();
playNext(game, game.getActivePlayerId(), node);
}
}
if (game.isGameOver()) {
val = GameStateEvaluator.evaluate(playerId, game);
}
else if (node.getChildren().size() > 0) {
//declared attackers or blockers or triggered abilities
logger.fine("simulating -- attack/block/trigger added children:" + node.getChildren().size());
val = minimaxAB(node, filter, depth-1, alpha, beta);
}
else {
val = simulatePriority(node, game, filter, depth, alpha, beta);
}
}
if (logger.isLoggable(Level.FINE))
logger.fine("returning -- score: " + val + " depth:" + depth + " step:" + game.getTurn().getStepType() + " for player:" + game.getPlayer(node.getPlayerId()).getName());
return val;
}