示例#1
0
 public static void main(String[] args) {
   /**
    * Computing ALL computations for 8x8 takes 26,360,768 computations g1, or (8,7) takes the
    * longest; 2,503,040 a3, or (6,1) takes the shortest: 512 Average: 411,887
    */
   try {
     if (args[0].charAt(0) == '0') mutatedChessBoard();
     else if (args[0].length() == 1) { // these lines read coordings from (1,1) to (8,8)
       m = Integer.parseInt(args[0]) - 1; // converts the string to a 0-7 int scale for row
       n = Integer.parseInt(args[1]) - 1; // converts the string to a 0-7 int scale for column
       EightQueens(m, n);
     } else {
       // these lines are for reading from a chess board; ie, a1-h8
       n = (int) args[0].charAt(0) - 97; // converts the character to the column coordinate
       m =
           ((int) args[0].charAt(1) - 49 - (nByn - 1))
               * (-1); // converts the character to the row coordinate
       // m=((int)args[0].charAt(1)-49-7)*(-1);
       letterEightQueens(m, n);
     }
   } catch (Exception ex) {
     System.out.println(ex.getMessage());
     board.display();
     System.out.println("That is not a spot on the chessboard.");
     System.out.println("Chessboard locations: ");
     board.letterBoard();
     System.out.println("\nLayman's terms: ");
     board.coordinateBoard();
   }
 }