[Simulated AI] Add support for cards that need multiple targets.

Note: Currently, no special optimizations are made to try to prune decision trees for these, even though they definitely can result in a lot of choices and really slow simulation AI performance.
This commit is contained in:
Myrd
2017-01-08 21:02:24 +00:00
parent 94a5c12604
commit 88634bb0a0
9 changed files with 189 additions and 62 deletions

View File

@@ -421,7 +421,7 @@ public class GameSimulatorTest extends SimulationTestCase {
assertNotNull(sa);
sa.setActivatingPlayer(p);
PossibleTargetSelector selector = new PossibleTargetSelector(sa);
MultiTargetSelector selector = new MultiTargetSelector(sa, null);
while (selector.selectNextTargets()) {
GameSimulator sim = createSimulator(game, p);
sim.simulateSpellAbility(sa);

View File

@@ -171,4 +171,30 @@ public class SpellAbilityPickerTest extends SimulationTestCase {
String expected = "Fiery Confluence -> " + dmgOppStr + " " + dmgOppStr + " " + dmgOppStr;
assertEquals(expected, picker.getPlan().getDecisions().get(0).modesStr);
}
public void testMultipleTargets() {
Game game = initAndCreateGame();
Player p = game.getPlayers().get(1);
addCard("Mountain", p);
addCard("Mountain", p);
Card spell = addCardToZone("Arc Trail", p, ZoneType.Hand);
Player opponent = game.getPlayers().get(0);
Card bear = addCard("Runeclaw Bear", opponent);
Card men = addCard("Flying Men", opponent);
opponent.setLife(20, null);
game.getPhaseHandler().devModeSet(PhaseType.MAIN1, p);
game.getAction().checkStateEffects(true);
SpellAbilityPicker picker = new SpellAbilityPicker(game, p);
SpellAbility sa = picker.chooseSpellAbilityToPlay(null);
assertEquals(spell.getSpellAbilities().get(0), sa);
assertEquals(bear, sa.getTargetCard());
assertEquals("2", sa.getParam("NumDmg"));
SpellAbility subSa = sa.getSubAbility();
assertEquals(men, subSa.getTargetCard());
assertEquals("1", subSa.getParam("NumDmg"));
}
}