Search in sources :

Example 6 with CombatSimulator

use of mage.player.ai.simulators.CombatSimulator in project mage by magefree.

the class ComputerPlayer method addBlockSimulations.

protected void addBlockSimulations(List<Permanent> blockers, TreeNode<CombatSimulator> node, Game game) {
    int numGroups = node.getData().groups.size();
    Copier<CombatSimulator> copier = new Copier<>();
    for (Permanent blocker : blockers) {
        List<Permanent> subList = remove(blockers, blocker);
        for (int i = 0; i < numGroups; i++) {
            if (node.getData().groups.get(i).canBlock(blocker, game)) {
                CombatSimulator combat = copier.copy(node.getData());
                combat.groups.get(i).blockers.add(new CreatureSimulator(blocker));
                TreeNode<CombatSimulator> child = new TreeNode<>(combat);
                node.addChild(child);
                addBlockSimulations(subList, child, game);
                combat.simulate(game);
            }
        }
    }
}
Also used : Permanent(mage.game.permanent.Permanent) FilterPermanent(mage.filter.FilterPermanent) CombatSimulator(mage.player.ai.simulators.CombatSimulator) CreatureSimulator(mage.player.ai.simulators.CreatureSimulator)

Aggregations

CombatSimulator (mage.player.ai.simulators.CombatSimulator)6 FilterPermanent (mage.filter.FilterPermanent)4 Permanent (mage.game.permanent.Permanent)4 CombatGroupSimulator (mage.player.ai.simulators.CombatGroupSimulator)2 CreatureSimulator (mage.player.ai.simulators.CreatureSimulator)2 CombatGroup (mage.game.combat.CombatGroup)1