image thumbnail

Knight's Tour

version 1.0.0 (2.57 KB) by Martin Thomas
Functions to complete an open knight's tour on an N*N chessboard


Updated 16 Dec 2019

View License

The knight's tour is a problem of a knight visiting every square of a chessboard without revisiting any square; following the same movement rules it has while in a game of chess. An open knight's tour does not start where it began, as a closed tour would. This problem can be dated as far back as the 9th Century

This code creates an N*N chessboard and the knight then attempts to travel the full board, starting from (1,1). This algorithm brute forces, but the StepCheck function ensures that previously visited squares aren't chosen.

Cite As

Martin Thomas (2021). Knight's Tour (, MATLAB Central File Exchange. Retrieved .

MATLAB Release Compatibility
Created with R2019b
Compatible with any release
Platform Compatibility
Windows macOS Linux

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!