java 12.0.2 2019-07-16
Java(TM) SE Runtime Environment (build 12.0.2+10)
MacOS Catalina 10.15 Beta (19A558d)
~/assignment1$ make
~/assignment1$ java -cp out NQueenSolver . 5
~/assignment1$ cat result5.txt
~/assignment1$ make clean
Main function. Find a solution of N-Queens problem and write result on file.
@param args args[0]
is absolute path of output file, and args[1]
is parameter N of N-queens problem.
Run NQueenSolverInterface
objects and write results on outfile
.
@param solvers Array of NQueenSolverInterface
objects.
@param N Size of the chess board.
@throws IOException On output error.
Represents a board state of N-Queens problem.
Check if the state satisfies the rules of N-Queens problem.
@param N parameter of N-Queens problem.
@return If the state is okay, return true. Otherwise, return false.
Get all possible next state of board.
@param boardSize Size of the board.
@return Array of NQueenState
objects.
Interface for N-Queen problem solver classes.
Returns the name of algorithm it uses. @return name of algorithm
Solves N-Queen problem and returns a solution which is firstly found.
@param boardSize Size of the board.
@return If solution is found, return a NQueenState
object describes the state of board. Otherwise, return null.
> DFS
No solution
Elapsed time: 0.0s
> BFS
Location:
Elapsed time: 0.0s
> DFID
No solution
Elapsed time: 0.0s
> DFS
Location: 4 2 0 3 1
Elapsed time: 0.002s
> BFS
Location: 0 2 4 1 3
Elapsed time: 0.003s
> DFID
Location: 4 2 0 3 1
Elapsed time: 0.001s
> DFS
Location: 6 4 2 0 5 3 1
Elapsed time: 0.033s
> BFS
Location: 0 2 4 6 1 3 5
Elapsed time: 0.139s
> DFID
Location: 6 4 2 0 5 3 1
Elapsed time: 0.047s