Guest User

Untitled

a guest
Oct 23rd, 2016
58
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.73 KB | None | 0 0
  1. public MOVE bfs(Game state){
  2. EnumMap<GHOST,MOVE> ghostMove = new EnumMap<>(GHOST.class);
  3. MOVE bestMove = MOVE.NEUTRAL;
  4. Queue<Game> q = new LinkedList<>();
  5. q.add(state.copy());
  6. while(!q.isEmpty()){
  7. Game current = q.peek();
  8. q.remove();
  9. for (MOVE move : current.getPossibleMoves (current.getPacmanCurrentNodeIndex())) {
  10. Game neighbor = state.copy();
  11. neighbor.advanceGame(move, ghostMove);
  12. q.add(neighbor);
  13. if ((current.getNumberOfActivePills() == 0) && (current.getNumberOfActivePowerPills() == 0)) {
  14. return move;
  15. }
  16.  
  17. }
  18. }
  19. return bestMove;
  20. }
Add Comment
Please, Sign In to add comment