Advertisement
Guest User

Test maze

a guest
Jan 3rd, 2021
15
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.97 KB | None | 0 0
  1. import java.util.ArrayList;
  2.  
  3. public class TestMazeDFS {
  4.     private static int[][] maze = {
  5.             {1, 1, 1, 1, 1, 1, 1, 1, 1},       
  6.             {1, 0, 0, 0, 0, 0, 0, 0, 1},
  7.             {1, 0, 1, 0, 1, 1, 1, 1, 1},
  8.             {1, 0, 1, 0, 0, 0, 0, 0, 1},
  9.             {1, 1, 1, 1, 1, 0, 1, 0, 1},
  10.             {1, 0, 0, 0, 1, 0, 1, 0, 1},
  11.             {1, 0, 1, 1, 1, 1, 1, 0, 1},
  12.             {1, 0, 0, 0, 0, 0, 0 ,3, 1},
  13.             {1, 1, 1, 1, 1, 1, 1, 1, 1},
  14.         };
  15.    
  16.     public int[][] getMaze(){
  17.        
  18.         return this.maze;
  19.     }
  20.    
  21.     // prints the maze.
  22.     public static void printMaze() {
  23.         for (int i = 0; i < 9; i++) {
  24.             for (int j = 0; j < 9; j++) {
  25. //              if (maze[i][j] == 1) {
  26. //                  System.out.print('#');
  27. //              } else {
  28. //                  System.out.print(' ');
  29. //              }
  30.                 System.out.print(maze[i][j]);
  31.             }
  32.             System.out.println();
  33.         }
  34.         System.out.println();
  35.     }
  36.    
  37.     public static void main(String[] args) {
  38.         TestMazeDFS maze = new TestMazeDFS();
  39.         boolean test = DFS.solve(maze.getMaze(), 1, 1);
  40.         System.out.println(test);
  41.         printMaze();
  42.        
  43.     }
  44. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement