package net.ciklum.icfpc11.controller.ai; import junit.framework.TestCase import net.ciklum.icfpc11.domain.Game import net.ciklum.icfpc11.controller.Controller import net.ciklum.icfpc11.parser.Command /** * blabla * * @author vic */ public class ReviveStrategyTest extends TestCase { Game game Controller controller @Override protected void setUp() { game = Game.push() controller = new Controller(game) } @Override protected void tearDown() { Game.pop() } void testNormalPath() { final int TO_REVIVE = 255 game.currentProponent.getSlot(TO_REVIVE).vitality = 0 ReviveStrategy rs = new ReviveStrategy(game, TO_REVIVE, 177) while (!rs.complete) { assertFalse rs.complete Command c = rs.getNextCommand() println c controller.applyCommand(c) } assertEquals 1, game.currentProponent.getSlot(TO_REVIVE).vitality assertTrue rs.complete } void testKilledAddress() { final int TO_REVIVE = 255 game.currentProponent.getSlot(TO_REVIVE).vitality = 0 ReviveStrategy rs = new ReviveStrategy(game, TO_REVIVE, 177) (1..5).each { assertFalse rs.complete Command c = rs.getNextCommand() controller.applyCommand(c) } game.currentProponent.getSlot(177).vitality = 0 assertTrue rs.complete try { rs.getNextCommand() fail 'should fail here' } catch (IndexOutOfBoundsException) { } } }