Question: write a java program for the following question: Knight's tour problem Consider a NxN chessboard, with the Knight moving according to Chess rules. When it

write a java program for the following question:

write a java program for the following question: Knight's tour problem Consider

Knight's tour problem Consider a NxN chessboard, with the Knight moving according to Chess rules. When it moves, it can move to a square that is two squares horizontally and one square vertically, or two squares vertically and one square horizontally. The complete move therefore looks like the letter L. The Knight may move at most in 8 different cells (see Figure below) We want to find a sequence of moves for the Knight where all cells in the chessboard are visited, but each cell is touched exactly once. The starting point is arbitrary Make a solution consisting of three classes: Chessboard, KnightMove and Cell. A Chessboard has (at least) two data fields: int size to specify the size of the chessboard (i.e. number of rows/columns), andint[ [ touched to indicate whether or not a certain cell is already touched. You might want to implement methods to occupy and free cells in the chessboard. A KnightMove has (at least) one data field: int offsets to specify the Knight's starting point on the chessboard. This class should have a method with the following header: ArrayList findLegalMoves (Chessboard cb) which returns the collection of moves (i.e. a sequence of cells that can be visited by the Knight) that solves the Knight's tour problem. A Cell has (at least) two data fields: int i andint jto refer to a specific cell in the ith row and jth column of the chessboard. In the chessboard below a sequence of Knight moves is shown: (0,0), (2,1), (3,3). findLegalMoves (... returns the sequence of all moves to solve the Knight's

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!