Advertisement
Guest User

Untitled

a guest
Oct 13th, 2019
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.67 KB | None | 0 0
  1. public static void getSuccessors(Configuration board, int row, ArrayList<Configuration> successors, int X){
  2.       if(row >= X-1){
  3.         if(isValid(board)){
  4.           successors.add(board);
  5.           return;
  6.         }
  7.       } else {
  8.         for(int i = 1; i < (2 * X)-1; i++){
  9.           for(int j = i+1; j < (2 * X)-1; j++){
  10.             Configuration newBoard = new Configuration(X);
  11.             Arrays.fill(newBoard.getConfiguration()[row], i, j+1, 1);
  12.             System.out.println("NewBoard (Row=" + row + ")");
  13.             System.out.println(newBoard.toString());
  14.             getSuccessors(newBoard, row+1, successors, X);
  15.           }
  16.         }
  17.       }
  18.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement