AnyGhostEdibleModeSelector extends MsPacManModeSelector { public int mode() { return gs.anyIsEdible() ? SOME_EDIBLE_GHOST : NO_EDIBLE_GHOSTS; } AnyGhostEdibleModeSelector(); int mode(); int numModes(); @Override /** * gets the associated fitness scores with this mode selector based on human * selected parameters * * @return an int array holding the score for no edible ghosts in the first * index and the score for some edible ghosts in the second index */ int[] associatedFitnessScores(); static final int NO_EDIBLE_GHOSTS; static final int SOME_EDIBLE_GHOST; final boolean awardProperPowerPillEating; final boolean punishImproperPowerPillEating; final boolean levelObjective; }
@Test public void testMode() { GameFacade g = new GameFacade(new Game(0)); EnumMap<GHOST,MOVE> gm = new EnumMap<GHOST,MOVE>(GHOST.class); gm.put(GHOST.BLINKY, MOVE.NEUTRAL); gm.put(GHOST.INKY, MOVE.NEUTRAL); gm.put(GHOST.PINKY, MOVE.NEUTRAL); gm.put(GHOST.SUE, MOVE.NEUTRAL); g.newG.advanceGame(MOVE.LEFT, gm); select.giveGame(g); assertEquals(AnyGhostEdibleModeSelector.NO_EDIBLE_GHOSTS, select.mode()); while(g.anyActiveGhostInLair()) { g.newG.advanceGame(MOVE.LEFT, gm); } select.giveGame(g); assertEquals(AnyGhostEdibleModeSelector.NO_EDIBLE_GHOSTS, select.mode()); g.newG.advanceGame(MOVE.DOWN, gm); g.newG.advanceGame(MOVE.DOWN, gm); g.newG.advanceGame(MOVE.DOWN, gm); g.newG.advanceGame(MOVE.DOWN, gm); g.newG.advanceGame(MOVE.DOWN, gm); g.newG.advanceGame(MOVE.DOWN, gm); g.newG.advanceGame(MOVE.DOWN, gm); g.newG.advanceGame(MOVE.DOWN, gm); g.newG.advanceGame(MOVE.DOWN, gm); g.newG.advanceGame(MOVE.DOWN, gm); g.newG.advanceGame(MOVE.DOWN, gm); g.newG.advanceGame(MOVE.DOWN, gm); g.newG.advanceGame(MOVE.DOWN, gm); g.newG.advanceGame(MOVE.DOWN, gm); g.newG.advanceGame(MOVE.DOWN, gm); g.newG.advanceGame(MOVE.DOWN, gm); select.giveGame(g); assertEquals(AnyGhostEdibleModeSelector.SOME_EDIBLE_GHOST, select.mode()); g.newG.advanceGame(MOVE.UP, gm); g.newG.advanceGame(MOVE.UP, gm); g.newG.advanceGame(MOVE.UP, gm); g.newG.advanceGame(MOVE.UP, gm); g.newG.advanceGame(MOVE.UP, gm); g.newG.advanceGame(MOVE.UP, gm); g.newG.advanceGame(MOVE.UP, gm); g.newG.advanceGame(MOVE.UP, gm); g.newG.advanceGame(MOVE.UP, gm); g.newG.advanceGame(MOVE.RIGHT, gm); g.newG.advanceGame(MOVE.RIGHT, gm); g.newG.advanceGame(MOVE.RIGHT, gm); g.newG.advanceGame(MOVE.RIGHT, gm); g.newG.advanceGame(MOVE.RIGHT, gm); g.newG.advanceGame(MOVE.RIGHT, gm); g.newG.advanceGame(MOVE.RIGHT, gm); g.newG.advanceGame(MOVE.RIGHT, gm); g.newG.advanceGame(MOVE.UP, gm); g.newG.advanceGame(MOVE.UP, gm); g.newG.advanceGame(MOVE.UP, gm); g.newG.advanceGame(MOVE.UP, gm); g.newG.advanceGame(MOVE.UP, gm); g.newG.advanceGame(MOVE.UP, gm); g.newG.advanceGame(MOVE.UP, gm); g.newG.advanceGame(MOVE.UP, gm); g.newG.advanceGame(MOVE.UP, gm); g.newG.advanceGame(MOVE.UP, gm); g.newG.advanceGame(MOVE.UP, gm); g.newG.advanceGame(MOVE.UP, gm); g.newG.advanceGame(MOVE.UP, gm); g.newG.advanceGame(MOVE.UP, gm); g.newG.advanceGame(MOVE.UP, gm); g.newG.advanceGame(MOVE.UP, gm); g.newG.advanceGame(MOVE.UP, gm); g.newG.advanceGame(MOVE.UP, gm); g.newG.advanceGame(MOVE.UP, gm); g.newG.advanceGame(MOVE.UP, gm); g.newG.advanceGame(MOVE.UP, gm); g.newG.advanceGame(MOVE.UP, gm); g.newG.advanceGame(MOVE.UP, gm); g.newG.advanceGame(MOVE.UP, gm); g.newG.advanceGame(MOVE.UP, gm); g.newG.advanceGame(MOVE.UP, gm); g.newG.advanceGame(MOVE.UP, gm); g.newG.advanceGame(MOVE.UP, gm); g.newG.advanceGame(MOVE.UP, gm); g.newG.advanceGame(MOVE.UP, gm); g.newG.advanceGame(MOVE.UP, gm); g.newG.advanceGame(MOVE.UP, gm); g.newG.advanceGame(MOVE.UP, gm); g.newG.advanceGame(MOVE.UP, gm); g.newG.advanceGame(MOVE.UP, gm); g.newG.advanceGame(MOVE.UP, gm); g.newG.advanceGame(MOVE.UP, gm); g.newG.advanceGame(MOVE.UP, gm); g.newG.advanceGame(MOVE.UP, gm); g.newG.advanceGame(MOVE.UP, gm); g.newG.advanceGame(MOVE.UP, gm); g.newG.advanceGame(MOVE.UP, gm); g.newG.advanceGame(MOVE.UP, gm); g.newG.advanceGame(MOVE.UP, gm); g.newG.advanceGame(MOVE.UP, gm); g.newG.advanceGame(MOVE.UP, gm); g.newG.advanceGame(MOVE.UP, gm); g.newG.advanceGame(MOVE.UP, gm); g.newG.advanceGame(MOVE.UP, gm); g.newG.advanceGame(MOVE.UP, gm); g.newG.advanceGame(MOVE.UP, gm); g.newG.advanceGame(MOVE.UP, gm); g.newG.advanceGame(MOVE.UP, gm); g.newG.advanceGame(MOVE.UP, gm); g.newG.advanceGame(MOVE.UP, gm); g.newG.advanceGame(MOVE.UP, gm); g.newG.advanceGame(MOVE.UP, gm); g.newG.advanceGame(MOVE.UP, gm); g.newG.advanceGame(MOVE.UP, gm); g.newG.advanceGame(MOVE.UP, gm); g.newG.advanceGame(MOVE.UP, gm); g.newG.advanceGame(MOVE.UP, gm); g.newG.advanceGame(MOVE.UP, gm); g.newG.advanceGame(MOVE.UP, gm); g.newG.advanceGame(MOVE.UP, gm); g.newG.advanceGame(MOVE.UP, gm); g.newG.advanceGame(MOVE.UP, gm); g.newG.advanceGame(MOVE.UP, gm); g.newG.advanceGame(MOVE.UP, gm); g.newG.advanceGame(MOVE.UP, gm); g.newG.advanceGame(MOVE.UP, gm); g.newG.advanceGame(MOVE.UP, gm); select.giveGame(g); assertEquals(AnyGhostEdibleModeSelector.SOME_EDIBLE_GHOST, select.mode()); g.newG.advanceGame(MOVE.DOWN, gm); g.newG.advanceGame(MOVE.DOWN, gm); g.newG.advanceGame(MOVE.DOWN, gm); g.newG.advanceGame(MOVE.DOWN, gm); g.newG.advanceGame(MOVE.DOWN, gm); g.newG.advanceGame(MOVE.DOWN, gm); g.newG.advanceGame(MOVE.DOWN, gm); g.newG.advanceGame(MOVE.DOWN, gm); g.newG.advanceGame(MOVE.DOWN, gm); g.newG.advanceGame(MOVE.DOWN, gm); g.newG.advanceGame(MOVE.DOWN, gm); g.newG.advanceGame(MOVE.DOWN, gm); g.newG.advanceGame(MOVE.RIGHT, gm); g.newG.advanceGame(MOVE.RIGHT, gm); g.newG.advanceGame(MOVE.RIGHT, gm); g.newG.advanceGame(MOVE.RIGHT, gm); g.newG.advanceGame(MOVE.RIGHT, gm); g.newG.advanceGame(MOVE.RIGHT, gm); g.newG.advanceGame(MOVE.RIGHT, gm); g.newG.advanceGame(MOVE.RIGHT, gm); g.newG.advanceGame(MOVE.RIGHT, gm); g.newG.advanceGame(MOVE.RIGHT, gm); select.giveGame(g); assertEquals(AnyGhostEdibleModeSelector.SOME_EDIBLE_GHOST, select.mode()); g.newG.advanceGame(MOVE.RIGHT, gm); g.newG.advanceGame(MOVE.RIGHT, gm); g.newG.advanceGame(MOVE.RIGHT, gm); g.newG.advanceGame(MOVE.RIGHT, gm); g.newG.advanceGame(MOVE.RIGHT, gm); g.newG.advanceGame(MOVE.RIGHT, gm); g.newG.advanceGame(MOVE.RIGHT, gm); g.newG.advanceGame(MOVE.RIGHT, gm); g.newG.advanceGame(MOVE.RIGHT, gm); g.newG.advanceGame(MOVE.RIGHT, gm); select.giveGame(g); assertEquals(AnyGhostEdibleModeSelector.SOME_EDIBLE_GHOST, select.mode()); g.newG.advanceGame(MOVE.LEFT, gm); g.newG.advanceGame(MOVE.LEFT, gm); g.newG.advanceGame(MOVE.LEFT, gm); g.newG.advanceGame(MOVE.UP, gm); g.newG.advanceGame(MOVE.UP, gm); g.newG.advanceGame(MOVE.UP, gm); g.newG.advanceGame(MOVE.UP, gm); g.newG.advanceGame(MOVE.UP, gm); g.newG.advanceGame(MOVE.UP, gm); g.newG.advanceGame(MOVE.UP, gm); g.newG.advanceGame(MOVE.UP, gm); g.newG.advanceGame(MOVE.UP, gm); g.newG.advanceGame(MOVE.UP, gm); g.newG.advanceGame(MOVE.UP, gm); g.newG.advanceGame(MOVE.UP, gm); g.newG.advanceGame(MOVE.UP, gm); g.newG.advanceGame(MOVE.UP, gm); g.newG.advanceGame(MOVE.UP, gm); g.newG.advanceGame(MOVE.UP, gm); g.newG.advanceGame(MOVE.UP, gm); g.newG.advanceGame(MOVE.UP, gm); g.newG.advanceGame(MOVE.UP, gm); g.newG.advanceGame(MOVE.UP, gm); g.newG.advanceGame(MOVE.UP, gm); g.newG.advanceGame(MOVE.UP, gm); g.newG.advanceGame(MOVE.UP, gm); g.newG.advanceGame(MOVE.UP, gm); g.newG.advanceGame(MOVE.UP, gm); g.newG.advanceGame(MOVE.UP, gm); g.newG.advanceGame(MOVE.UP, gm); g.newG.advanceGame(MOVE.UP, gm); g.newG.advanceGame(MOVE.UP, gm); g.newG.advanceGame(MOVE.UP, gm); g.newG.advanceGame(MOVE.UP, gm); g.newG.advanceGame(MOVE.UP, gm); g.newG.advanceGame(MOVE.UP, gm); g.newG.advanceGame(MOVE.UP, gm); g.newG.advanceGame(MOVE.UP, gm); g.newG.advanceGame(MOVE.UP, gm); g.newG.advanceGame(MOVE.UP, gm); g.newG.advanceGame(MOVE.UP, gm); g.newG.advanceGame(MOVE.UP, gm); g.newG.advanceGame(MOVE.UP, gm); g.newG.advanceGame(MOVE.UP, gm); g.newG.advanceGame(MOVE.UP, gm); g.newG.advanceGame(MOVE.UP, gm); g.newG.advanceGame(MOVE.UP, gm); g.newG.advanceGame(MOVE.UP, gm); g.newG.advanceGame(MOVE.UP, gm); g.newG.advanceGame(MOVE.UP, gm); g.newG.advanceGame(MOVE.UP, gm); g.newG.advanceGame(MOVE.RIGHT, gm); g.newG.advanceGame(MOVE.RIGHT, gm); g.newG.advanceGame(MOVE.RIGHT, gm); g.newG.advanceGame(MOVE.RIGHT, gm); g.newG.advanceGame(MOVE.RIGHT, gm); g.newG.advanceGame(MOVE.RIGHT, gm); g.newG.advanceGame(MOVE.RIGHT, gm); g.newG.advanceGame(MOVE.RIGHT, gm); g.newG.advanceGame(MOVE.RIGHT, gm); g.newG.advanceGame(MOVE.RIGHT, gm); g.newG.advanceGame(MOVE.RIGHT, gm); g.newG.advanceGame(MOVE.RIGHT, gm); g.newG.advanceGame(MOVE.RIGHT, gm); g.newG.advanceGame(MOVE.RIGHT, gm); g.newG.advanceGame(MOVE.RIGHT, gm); g.newG.advanceGame(MOVE.RIGHT, gm); g.newG.advanceGame(MOVE.RIGHT, gm); g.newG.advanceGame(MOVE.RIGHT, gm); g.newG.advanceGame(MOVE.RIGHT, gm); g.newG.advanceGame(MOVE.RIGHT, gm); g.newG.advanceGame(MOVE.RIGHT, gm); g.newG.advanceGame(MOVE.RIGHT, gm); g.newG.advanceGame(MOVE.RIGHT, gm); g.newG.advanceGame(MOVE.RIGHT, gm); g.newG.advanceGame(MOVE.RIGHT, gm); g.newG.advanceGame(MOVE.RIGHT, gm); g.newG.advanceGame(MOVE.RIGHT, gm); g.newG.advanceGame(MOVE.RIGHT, gm); g.newG.advanceGame(MOVE.RIGHT, gm); g.newG.advanceGame(MOVE.RIGHT, gm); g.newG.advanceGame(MOVE.RIGHT, gm); g.newG.advanceGame(MOVE.RIGHT, gm); select.giveGame(g); assertEquals(AnyGhostEdibleModeSelector.NO_EDIBLE_GHOSTS, select.mode()); g.newG.advanceGame(MOVE.RIGHT, gm); g.newG.advanceGame(MOVE.RIGHT, gm); g.newG.advanceGame(MOVE.RIGHT, gm); g.newG.advanceGame(MOVE.RIGHT, gm); g.newG.advanceGame(MOVE.RIGHT, gm); g.newG.advanceGame(MOVE.RIGHT, gm); g.newG.advanceGame(MOVE.RIGHT, gm); g.newG.advanceGame(MOVE.RIGHT, gm); g.newG.advanceGame(MOVE.RIGHT, gm); g.newG.advanceGame(MOVE.RIGHT, gm); g.newG.advanceGame(MOVE.RIGHT, gm); g.newG.advanceGame(MOVE.RIGHT, gm); g.newG.advanceGame(MOVE.RIGHT, gm); g.newG.advanceGame(MOVE.RIGHT, gm); g.newG.advanceGame(MOVE.RIGHT, gm); g.newG.advanceGame(MOVE.RIGHT, gm); g.newG.advanceGame(MOVE.RIGHT, gm); g.newG.advanceGame(MOVE.RIGHT, gm); g.newG.advanceGame(MOVE.RIGHT, gm); g.newG.advanceGame(MOVE.RIGHT, gm); g.newG.advanceGame(MOVE.RIGHT, gm); g.newG.advanceGame(MOVE.RIGHT, gm); g.newG.advanceGame(MOVE.RIGHT, gm); g.newG.advanceGame(MOVE.RIGHT, gm); g.newG.advanceGame(MOVE.RIGHT, gm); g.newG.advanceGame(MOVE.RIGHT, gm); g.newG.advanceGame(MOVE.RIGHT, gm); g.newG.advanceGame(MOVE.RIGHT, gm); g.newG.advanceGame(MOVE.RIGHT, gm); g.newG.advanceGame(MOVE.RIGHT, gm); g.newG.advanceGame(MOVE.RIGHT, gm); g.newG.advanceGame(MOVE.RIGHT, gm); g.newG.advanceGame(MOVE.RIGHT, gm); g.newG.advanceGame(MOVE.RIGHT, gm); g.newG.advanceGame(MOVE.RIGHT, gm); g.newG.advanceGame(MOVE.RIGHT, gm); g.newG.advanceGame(MOVE.RIGHT, gm); g.newG.advanceGame(MOVE.RIGHT, gm); g.newG.advanceGame(MOVE.RIGHT, gm); g.newG.advanceGame(MOVE.RIGHT, gm); g.newG.advanceGame(MOVE.RIGHT, gm); g.newG.advanceGame(MOVE.RIGHT, gm); g.newG.advanceGame(MOVE.RIGHT, gm); g.newG.advanceGame(MOVE.RIGHT, gm); g.newG.advanceGame(MOVE.RIGHT, gm); g.newG.advanceGame(MOVE.RIGHT, gm); g.newG.advanceGame(MOVE.RIGHT, gm); g.newG.advanceGame(MOVE.RIGHT, gm); g.newG.advanceGame(MOVE.RIGHT, gm); g.newG.advanceGame(MOVE.RIGHT, gm); g.newG.advanceGame(MOVE.RIGHT, gm); g.newG.advanceGame(MOVE.RIGHT, gm); g.newG.advanceGame(MOVE.UP, gm); g.newG.advanceGame(MOVE.UP, gm); g.newG.advanceGame(MOVE.UP, gm); g.newG.advanceGame(MOVE.UP, gm); g.newG.advanceGame(MOVE.UP, gm); g.newG.advanceGame(MOVE.UP, gm); g.newG.advanceGame(MOVE.UP, gm); g.newG.advanceGame(MOVE.UP, gm); g.newG.advanceGame(MOVE.UP, gm); g.newG.advanceGame(MOVE.UP, gm); g.newG.advanceGame(MOVE.UP, gm); g.newG.advanceGame(MOVE.UP, gm); g.newG.advanceGame(MOVE.UP, gm); g.newG.advanceGame(MOVE.UP, gm); g.newG.advanceGame(MOVE.UP, gm); g.newG.advanceGame(MOVE.UP, gm); g.newG.advanceGame(MOVE.UP, gm); g.newG.advanceGame(MOVE.UP, gm); g.newG.advanceGame(MOVE.UP, gm); g.newG.advanceGame(MOVE.UP, gm); g.newG.advanceGame(MOVE.UP, gm); g.newG.advanceGame(MOVE.UP, gm); select.giveGame(g); assertEquals(AnyGhostEdibleModeSelector.SOME_EDIBLE_GHOST, select.mode()); }