Sponsored Links
-->

Wednesday, March 28, 2018

Knights Tour 5x5.mp4 - YouTube
src: i.ytimg.com

A knight's tour is a sequence of moves of a knight on a chessboard such that the knight visits every square only once. If the knight ends on a square that is one knight's move from the beginning square (so that it could tour the board again immediately, following the same path), the tour is closed, otherwise it is open.

The knight's tour problem is the mathematical problem of finding a knight's tour. Creating a program to find a knight's tour is a common problem given to computer science students. Variations of the knight's tour problem involve chessboards of different sizes than the usual 8 × 8, as well as irregular (non-rectangular) boards.


Video Knight's tour



Theory

The knight's tour problem is an instance of the more general Hamiltonian path problem in graph theory. The problem of finding a closed knight's tour is similarly an instance of the Hamiltonian cycle problem. Unlike the general Hamiltonian path problem, the knight's tour problem can be solved in linear time.


Maps Knight's tour



History

The earliest known reference to the knight's tour problem dates back to the 9th century AD. In Rudra?a's Kavyalankara (5.15), a Sanskrit work on Poetics, the pattern of a knight's tour on a half-board has been presented as an elaborate poetic figure ("citra-ala?k?ra") called the "turagapadabandha" or 'arrangement in the steps of a horse.' The same verse in four lines of eight syllables each can be read from left to right or by following the path of the knight on tour. Since the Indic writing systems used for Sanskrit are syllabic, each syllable can be thought of as representing a square on a chess board. Rudrata's example is as follows:

transliterated:

For example, the first line can be read from left to right or by moving from the first square to second line, third syllable (2.3) and then to 1.5 to 2.7 to 4.8 to 3.6 to 4.4 to 3.2.

One of the first mathematicians to investigate the knight's tour was Leonhard Euler. The first procedure for completing the Knight's Tour was Warnsdorf's rule, first described in 1823 by H. C. von Warnsdorf.

In the 20th century, the Oulipo group of writers used it among many others. The most notable example is the 10 × 10 Knight's Tour which sets the order of the chapters in Georges Perec's novel Life a User's Manual.

The sixth game of the 2010 World Chess Championship between Viswanathan Anand and Veselin Topalov saw Anand making 13 consecutive knight moves (albeit using both knights); online commentors jested that Anand was trying to solve the Knight's Tour problem during the game.


The Knights Tour - Creating Real Mathematicians
src: www.creatingrealmathematicians.com


Existence

Schwenk proved that for any m × n board with m <= n, a closed knight's tour is always possible unless one or more of these three conditions are met:

  1. m and n are both odd
  2. m = 1, 2, or 4
  3. m = 3 and n = 4, 6, or 8.

Cull et al. and Conrad et al. proved that on any rectangular board whose smaller dimension is at least 5, there is a (possibly open) knight's tour.


C# Programming Challenge: 8-23 - Knight's Tour Part 1: Brute Force ...
src: i.ytimg.com


Number of tours

On an 8 × 8 board, there are exactly 26,534,728,821,064 directed closed tours (i.e. two tours along the same path that travel in opposite directions are counted separately, as are rotations and reflections). The number of undirected closed tours is half this number, since every tour can be traced in reverse. There are 9,862 undirected closed tours on a 6 × 6 board.

The number of directed open tours on an n × n board for n = 1, 2, ... are:

1; 0; 0; 0; 1,728; 6,637,920; 165,575,218,320; 19,591,828,170,979,904. (sequence A165134 in the OEIS).

Knight's Tour 01 | Fabric | Fabricut
src: cdn.fabricut.com


Finding tours with computers

There are quite a number of ways to find a knight's tour on a given board with a computer. Some of these methods are algorithms while others are heuristics.

Brute-force algorithms

A brute-force search for a knight's tour is impractical on all but the smallest boards; for example, on an 8 × 8 board there are approximately 4×1051 possible move sequences, and it is well beyond the capacity of modern computers (or networks of computers) to perform operations on such a large set. However, the size of this number gives a misleading impression of the difficulty of the problem, which can be solved "by using human insight and ingenuity ... without much difficulty."

Divide and conquer algorithms

By dividing the board into smaller pieces, constructing tours on each piece, and patching the pieces together, one can construct tours on most rectangular boards in linear time - that is, in a time proportional to the number of squares on the board.

Neural network solutions

The Knight's Tour problem also lends itself to being solved by a neural network implementation. The network is set up such that every legal knight's move is represented by a neuron, and each neuron is initialized randomly to be either "active" or "inactive" (output of 1 or 0), with 1 implying that the neuron is part of the final solution. Each neuron also has a state function (described below) which is initialized to 0.

When the network is allowed to run, each neuron can change its state and output based on the states and outputs of its neighbors (those exactly one knight's move away) according to the following transition rules:

U t + 1 ( N i , j ) = U t ( N i , j ) + 2 - ? N ? G ( N i , j ) V t ( N ) {\displaystyle U_{t+1}(N_{i,j})=U_{t}(N_{i,j})+2-\sum _{N\in G(N_{i,j})}V_{t}(N)}
V t + 1 ( N i , j ) = { 1 if U t + 1 ( N i , j ) > 3 0 if U t + 1 ( N i , j ) < 0 V t ( N i , j ) otherwise , {\displaystyle V_{t+1}(N_{i,j})=\left\{{\begin{array}{ll}1&{\mbox{if}}\,\,U_{t+1}(N_{i,j})>3\\0&{\mbox{if}}\,\,U_{t+1}(N_{i,j})<0\\V_{t}(N_{i,j})&{\mbox{otherwise}},\end{array}}\right.}

where t {\displaystyle t} represents discrete intervals of time, U ( N i , j ) {\displaystyle U(N_{i,j})} is the state of the neuron connecting square i {\displaystyle i} to square j {\displaystyle j} , V ( N i , j ) {\displaystyle V(N_{i,j})} is the output of the neuron from i {\displaystyle i} to j {\displaystyle j} , and G ( N i , j ) {\displaystyle G(N_{i,j})} is the set of neighbors of the neuron.

Although divergent cases are possible, the network should eventually converge, which occurs when no neuron changes its state from time t {\displaystyle t} to t + 1 {\displaystyle t+1} . When the network converges, either the network encodes a knight's tour or a series of two or more independent circuits within the same board.

Warnsdorf's rule

Warnsdorf's rule is a heuristic for finding a knight's tour. The knight is moved so that it always proceeds to the square from which the knight will have the fewest onward moves. When calculating the number of onward moves for each candidate square, we do not count moves that revisit any square already visited. It is, of course, possible to have two or more choices for which the number of onward moves is equal; there are various methods for breaking such ties, including one devised by Pohl and another by Squirrel and Cull.

This rule may also more generally be applied to any graph. In graph-theoretic terms, each move is made to the adjacent vertex with the least degree. Although the Hamiltonian path problem is NP-hard in general, on many graphs that occur in practice this heuristic is able to successfully locate a solution in linear time. The knight's tour is a special case.

The heuristic was first described in "Des Rösselsprungs einfachste und allgemeinste Lösung" by H. C. von Warnsdorf in 1823. A computer program that finds a knight's tour for any starting position using Warnsdorf's rule was written by Gordon Horsington and published in 1984 in the book Century/Acorn User Book of Computer Puzzles.


The Knight's Tour Java - YouTube
src: i.ytimg.com


See also

  • Abu-Bakr Muhammad ben Yahya as-Suli
  • George Koltanowski
  • Longest uncrossed knight's path
  • Eight queens puzzle

Knight's Tour | Lorem Ipsum
src: f4.bcbits.com


Notes


Knights Tour Puzzle - YouTube
src: i.ytimg.com


External links

  • OEIS sequence A001230 (Number of undirected closed knight's tours on a 2n X 2n chessboard)
  • H. C. von Warnsdorf 1823 in Google Books
  • Introduction to Knight's tours by George Jelliss
  • Knight's tours complete notes by George Jelliss

Source of article : Wikipedia