Advertisement
Guest User

Untitled

a guest
Nov 30th, 2015
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.73 KB | None | 0 0
  1.  
  2. maze.setStartPosition((maze.Rand(maze)));
  3.  
  4.  
  5. Position index=new Position(0,0,0);
  6. index=maze.getStartPosition();
  7.  
  8. Viz.push(index);
  9. maze.ChngeMaze(index.getX(), index.getY(),index.getZ() ,0 );
  10.  
  11.  
  12.  
  13. while(!Viz.isEmpty())
  14. {
  15.  
  16. po=(PosibleMoves(maze, index));
  17. if(!po.isEmpty())
  18. {
  19. num=rnd.nextInt(po.size());
  20. index=po.get(num);
  21. maze.ChngeMaze(index.getX(), index.getY(),index.getZ() ,0 );
  22. Viz.push(index);
  23.  
  24. }
  25. else
  26. {
  27. index=Viz.pop();
  28.  
  29. }
  30.  
  31.  
  32. }
  33. maze.setGoalPosition((maze.Rand(maze)));
  34. while (maze.getPosetion(maze.getGoalPosition())==1 || maze.getStartPosition().equals(maze.getGoalPosition())) {
  35. maze.setGoalPosition((maze.Rand(maze)));
  36. }
  37. return maze;
  38. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement