/* (non-Javadoc) * @see pacman.controllers.Controller#getMove(pacman.game.Game, long) */ public EnumMap<GHOST, MOVE> getMove(Game game, long timeDue) { int pacmanIndex = game.getPacmanCurrentNodeIndex(); for (GHOST ghost : GHOST.values()) { if (game.doesGhostRequireAction(ghost)) { int currentIndex = game.getGhostCurrentNodeIndex(ghost); // if ghosts are all in close proximity and not near Ms Pac-Man, disperse if (isCrowded(game) && !closeToMsPacMan(game, currentIndex)) myMoves.put(ghost, getRetreatActions(game, ghost)); // go towards the power pill locations // if edible or Ms Pac-Man is close to power pill, move away from Ms Pac-Man else if (game.getGhostEdibleTime(ghost) > 0 || closeToPower(game)) myMoves.put( ghost, game.getApproximateNextMoveAwayFromTarget( currentIndex, pacmanIndex, game.getGhostLastMoveMade(ghost), DM.PATH)); // move away from ms pacman // else go towards Ms Pac-Man else myMoves.put( ghost, game.getApproximateNextMoveTowardsTarget( currentIndex, pacmanIndex, game.getGhostLastMoveMade(ghost), DM.PATH)); // go towards ms pacman } } return myMoves; }