switch (player.getNextAction()) {
case PRIORITY:
// logger.info("Priority for player:" + player.getName() + " turn: " + game.getTurnNum() + " phase: " + game.getPhase().getType() + " step: " + game.getStep().getType());
List<Ability> abilities = player.getPlayableOptions(game);
for (Ability ability: abilities) {
Game sim = game.copy();
// logger.info("expand " + ability.toString());
MCTSPlayer simPlayer = (MCTSPlayer) sim.getPlayer(player.getId());
simPlayer.activateAbility((ActivatedAbility)ability, sim);
sim.resume();
children.add(new MCTSNode(this, sim, ability));
}
break;
case SELECT_ATTACKERS:
// logger.info("Select attackers:" + player.getName());
List<List<UUID>> attacks = player.getAttacks(game);
UUID defenderId = game.getOpponents(player.getId()).iterator().next();
for (List<UUID> attack: attacks) {
Game sim = game.copy();
MCTSPlayer simPlayer = (MCTSPlayer) sim.getPlayer(player.getId());
for (UUID attackerId: attack) {
simPlayer.declareAttacker(attackerId, defenderId, sim, false);
}
sim.resume();
children.add(new MCTSNode(this, sim, sim.getCombat()));
}
break;
case SELECT_BLOCKERS:
// logger.info("Select blockers:" + player.getName());
List<List<List<UUID>>> blocks = player.getBlocks(game);
for (List<List<UUID>> block: blocks) {
Game sim = game.copy();
MCTSPlayer simPlayer = (MCTSPlayer) sim.getPlayer(player.getId());
List<CombatGroup> groups = sim.getCombat().getGroups();
for (int i = 0; i < groups.size(); i++) {
if (i < block.size()) {
for (UUID blockerId: block.get(i)) {
simPlayer.declareBlocker(simPlayer.getId(), blockerId, groups.get(i).getAttackers().get(0), sim);
}
}
}
sim.resume();
children.add(new MCTSNode(this, sim, sim.getCombat()));
}
break;
}
game = null;
}