I'm at the planning stage of my code and I'm happy I can do most of it. the only thing that perplexes me slightly is the following.
In order to make the code more effective each square of the chess board is given a number reflecting its "accessibility". The lower th number the less accesible it is. The corners unsurprisingly are the least accessible with accessibility 2.
Code:
int board[8][8] = {2,3,4,4,4,4,3,2,
3,4,6,6,6,6,4,3,
4,6,8,8,8,8,6,4,
4,6,8,8,8,8,6,4,
4,6,8,8,8,8,6,4,
4,6,8,8,8,8,6,4,
3,4,6,6,6,6,4,3,
2,3,4,4,4,4,3,2,}
now the knight as you probably know can move two squares in either a vertical or horizontal direction + 1 square in a direction perpendicular to the first 2.
A centrally located has 8 possible moves which he can make. The idea is to move to the square that is least accesible. If there is a tie for the least accessible square you must run the analysis again on the two tied squares and so on till you find the a path that leads to an individual least accessible square.
The only was I saee to do it is to have an array with
value i j calling array calling x calling y
ie. eash time you have a tie you have create a new array detailing the tied squares and the array from which they were called. When the least accessible square is identified you can go back looking at the calling array to find the optimal path.
However this seems quite a clunky way of doing it. Involving several arrays that have to be stored in memory. Is there a better methos to resolve this problem? It seems almost like a recursive problem but it bracnches rather than producing a simpler case.