First, of all let me say that the function needs to be implements recursively, in java
, and MUST FIND a knights tour ever single time. I've spend alot
of time trying to implement this and have gone through about 4 functions for the traverse. Alright the specific question is, where can I put the traverse function call recursively so that the function will tour the entire chess. Board as it is now the knight only moves once and the program returns false. I've tried to methods to doing this, one jumping the knight into the square and then checking if the knight is still on the board, and two checking if the knight can jump to the square first and then jumping if the spot is valid.
I know that this flies against both the philosophy and regulations of javaranch. For details, please look here: DoYourOwnHomework
Please ask a specific question about your code that can be answered and you will likely quickly receive many helpful answers.
I'm sorry about not showing that I've shown effort. But, I've got to point in the program where I just have hit a BRICK WALL, I keep taking tid bids of advice from many people and try to apply them. These two functions are a result of applying my own knowledge about programming concepts and advice from others. And the program ends up producing bad output on me. I have a hard time understanding recursion.
I noticed that whenever the knight moves out of the bounds of the array the program justs ends because it can no longer enter into any of the if statements.
if(hor < 0...) in the first move hor ends up being -1 or -2 so program just returns false at the end. I don't know how to fix this though. Any ideas? I think this has to do with backtracking. I don't know how to get this program to backtrack correctly.