Advertisement
Guest User

Untitled

a guest
Dec 14th, 2019
119
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.74 KB | None | 0 0
  1. public boolean takeStep (int x, int y)
  2. {
  3. while (x<= in1 && 0<x )
  4. {
  5.  
  6. if (maze[x][y] == 'E')
  7. {
  8. return true;
  9. }
  10.  
  11. if (maze[x][y] == 'W' || maze[x][y] == '*')
  12. {
  13. return false;
  14. }
  15.  
  16. maze[x][y] = '*';
  17.  
  18. boolean result;
  19.  
  20. result = takeStep(x, y+1);
  21.  
  22. if (result) { return true;}
  23.  
  24. result = takeStep(x-1, y);
  25.  
  26. if (result) { return true;}
  27.  
  28. result = takeStep(x, y-1);
  29.  
  30. if (result) { return true;}
  31.  
  32. result = takeStep(x+1, y);
  33.  
  34. if (result) { return true;}
  35.  
  36. maze[x][y] = ' ';
  37.  
  38. return false;
  39. }
  40. return false;
  41. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement