Currently I have a knight's tour algorithm that is working.
I uses a combination of:
- Backtracking
- Warnsdorf's Rule
The algorithm does the following:
Checks to see if the board is solved (all squares visited)
If true: return true
else proceed:
Make a set of possible moves from current positions
Sort the set based on the number of moves available from those positions.
Go through the set. (Recursive call made here)
If returned True:
Set Solution board to appropriate number
Return true
else
go back to last position
return false.
It works okay. It is not the best solution.
I am trying to increase the speed using parallelization, in particular, using C++ threading (#include<thread>
).
What is the algorithm for this? So far the only ways I have tried have false sharing issues, shared memory issues or won't run at all.