HOME | DD

Fresh-Grass — Knight's Tour

Published: 2010-08-22 11:55:54 +0000 UTC; Views: 393; Favourites: 0; Downloads: 0
Redirect to original
Description Knight's Tour is common chess problem, the task is to find a route for knight through all squares on the board by making a move to each square only once.

I've seen quite a few people write the algorithm for knight's movement ("L-move") with if statements or something similar, but it can be done more efficiently with mathematical formula.
My formula for knights movement:
i= (0,1); j= (0,1); k= (1,2)
x movement: k*(i*2-1)
y movement: (k-3)*(j*2-1)

The algorithm for "Knight's Tour" with user interface in 3 different languages:
C++: [link]
C#: [link]
Java: [link]

User can define board size (NxM) and starting position.
Related content
Comments: 0