Problem description
In the given size of the checkerboard, the chess piece "horse" in the designated starting position, the pawn "horse" rule for the son must go on the chessboard "Day" word; Starting from the starting position of the chess piece "horse", search out a feasible path, make the pawn "horse" can go through all the drop points on the chessboard, and each drop point can walk only once;
For example: The chessboard size is 5*5, the chess piece Ma Fang's starting Drop point is (3, 3); The algorithm needs to search for a section starting from the position (3, 3) including the (1,1),(1,2),(1,3)... (5, 1), (5, 2), (5, 3), (5, 4), (5, 5) in total 25 can be drop all positions;
Problem analysis
Through the above problem description, we have a correct understanding of the content of the problem, and then we begin to make a detailed analysis of the problem, in order to find the correct solution to the problem of reasonable and feasible method;
First of all, we need to use the appropriate data structure in the program to represent the board in question, pieces, pieces of the process of walking; Next we need to analyze the core issues, that is, how to search for a feasible path, what strategy to search, how to express the search process;
For a chessboard of size n*m size, the piece starts at the current position (x, y) and can reach the next position (x ', y '):
(1) (x +1, y +2)
(2) (x +1, Y–2)
(3) (x–1, y +2)
(4) (x–1, y–2)
(5) (x +2, y + 1)
(6) (x +2, y–1)
(7) (x-2, y + 1)
(8) (X-2, y–1)