Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public MOVE bfs(Game state){
- EnumMap<GHOST,MOVE> ghostMove = new EnumMap<>(GHOST.class);
- MOVE bestMove = MOVE.NEUTRAL;
- Queue<Game> q = new LinkedList<>();
- q.add(state.copy());
- while(!q.isEmpty()){
- Game current = q.peek();
- q.remove();
- for (MOVE move : current.getPossibleMoves (current.getPacmanCurrentNodeIndex())) {
- Game neighbor = state.copy();
- neighbor.advanceGame(move, ghostMove);
- q.add(neighbor);
- if ((current.getNumberOfActivePills() == 0) && (current.getNumberOfActivePowerPills() == 0)) {
- return move;
- }
- }
- }
- return bestMove;
- }
Add Comment
Please, Sign In to add comment