Presentation on theme: "Can visit all squares of a chessboard exactly once ?"— Presentation transcript:
1 Can visit all squares of a chessboard exactly once ? by Krishna Mahesh Deevela Murali
2 Overview Problem Statement of Real World Problem Basic Concepts Formulating Graph ProblemSolution to Graph Problem and Real world ProblemInteresting Facts
3 Can visit all squares of a chessboard exactly once ? Our real world Problem is a very simple Question, it is to find if a Knight can legally visit every square on a Chessboard only once and Return to Starting position?If Knight’s tour Exist ??If Yes!! when does it happen??If Not!!! Why??Topic sounds Interesting rite… so lets not waste time and jump into topic just like the Knight …
4 Basics: The Knight’s Legal Moves: Each move of a Knight comprises 2 directions as specified below.Explain how the knight moves just in case the audience can’t recall.8 Possible Moves:2UP, 1 left2 UP, 1Right1UP, 2Left1UP, 2Right2Down, 1 left2 Down, 1Right1Down, 2Left1Down, 2Right
5 Solution to Graph Problem Hamilton CircuitA Hamiltonian cycle (or Hamiltonian circuit) is a cycle in an undirected graph which visits each vertex exactly once and also returns to the starting vertex. E.g 0,1,2,3,0Hamilton PathA path visits each vertex of a graph once and only once. E.g 0,1,2,3
6 Formulating Graph Problem In a chessboard the vertices would represent the squares of the board and the edges would represent a knight’s legal moves between squares results in a graph as shown below, Known as Knight’s graph.Highlights :Every Vertex represents square on chessboard.Every edge is one legal move of a Knight.
7 Special Properties of Knight’s Graph MxN chessboard has MN vertices. i.e Number of Squares equal to Vertices.Graph is Undirected.Edges of equal length, i.e one legal Knight Move.Knight’s Move is Symmetric. A to B is equal to B to A.Every move of knight Alternates between black and white. i.e move from white square will always result in an ending position on a black square and vice-versa
8 Solution to Graph Problem The Knight’s Tour is a well-known classic problem. The objective is to move a knight, starting from any square on a chessboard, to every other square once. Note that the knight makes only L-shaped moves (two spaces in one direction and one space in a perpendicular direction). If we observe the Knight's Tour problem turns out to be an instance of the more general Hamiltonian path problem in graph theory. The problem of getting a closed Knight's Tour is similarly an instance of the Hamiltonian cycle problem.
9 Solution to Graph Problem We have 2 types of solutions, Hamiltonian Path when Knight starts at a vertex and doesn't end at the same vertex, Open Knight tour. Hamiltonian Cycle where starting vertex and final vertex is the same, thus resulting a Cycle, Closed tour. The Solution to both Closed and Open tour are same just that start and final vertices are going to same and different correspondingly.
10 Algorithm:We can use simple algorithm to find if Knights tour Exists on the given board or not.M x N be size of board i.e mn number of squares.Total number of moves would be A=m*n-1.Visited be a two dimentional array [M][N] initialized to false, when Knight visits this square it is set to true.I be integer between 0 & A representing the number of moves, intialially it is 0, and if knight completes the Path it is A.After Completeting the path if the one of next possible move results to initial position, it is a Closed tour, else it is Open Tour.
11 Algorithm move(x,y,i)if( (x < 0) OR (x ≥ M) OR (y < 0) OR (y ≥ N) )return falseif( visited[x, y] = true ) return falseif( m = M ) print “A solution has been found”print “ x, y ” //This starts printing the solutionset visited[x, y] = truereturn trueelse //This is a valid move, but a tour has not been completed.set result = false OR Move( x+2, y+1, m+1)set result = false OR Move( x+2, y-1, m+1)set result = false OR Move( x-2, y+1, m+1)set result = false OR Move( x-2, y-1, m+1)set result = false OR Move( x+1, y+2, m+1)set result = false OR Move( x+1, y-2, m+1)set result = false OR Move( x-1, y+2, m+1)set result = false OR Move( x-1, y-2, m+1)
12 Algorithm move(x,y,i) contd.. 4. if( result = true ) //One of the 8 moves above led to a completed tour.print “ x, y ”return trueElse //None of the moves from this position led to a successful tour. //Now we must backtrack and try a different pathset visited[x, y] = false //Unvisit this locationreturn falseHence our Real World Problem is Solved.. Using Knights Graph and Basic Graph Theory.
13 The Closed Knight’s Tour The Open Knight’s Tour where start and final vertex are differentAre you finding it hard to believe this would even work... Then take a live look.
14 100 ?? 10000?? 1 ?? No No No… it is biggerrrrrr 26,534,728,821,064 How many closed knight’s tours are there on an 8 × 8 board?How many open knight’s tours are there on an 8 × 8 board?100 ??10000??1 ??No No No… it is biggerrrrrr26,534,728,821,064If we have to find all the closed paths everyhuman has to find 3500 diff pathsPopulation of world 7 billion but no of paths are26 trillion19,591,828,170,979,90419 Quadrillion
15 When does this Closed Knight’s Tour occur In 1991, Allen Schwenk completely determined which rectangular chessboards have a closed knight’s tour.An m × n chessboard with m <= n has a closed knight’s tour unless one or more of the following three conditions hold:(a) m and n are both odd;(b) m = 1, 2 or 4 ;(c) m = 3 and n = 4, 6 or 8.(explaination is not given due tocomplexity and time for condition c)
16 Condition (a): m and n are both odd. Recall that a legal move for a knight whose initial position is a white square will always result in an ending position on a black square and vice-versa.Hence, every tour representing the legal moves of a knight alternates between black and white squares.
17 Condition (a): m and n are both odd. Suppose m and n are both odd.There will exist an odd number of squares on the board.The number of black squares will not equal the number of white squares.No closed tour can exist.
18 Condition (b): m = 1, 2 or 4.Suppose m = 1Suppose m = 2
19 Condition (b): m = 1, 2 or 4.For 4 × n boards we require a more complex coloring of the board than the traditional black and white coloring.
20 Condition (b): m = 1, 2 or 4.Note that a knight must move from a brown square to a black square. Likewise, a knight must move from a white square to a green square. Two closed cycles are now forced to exist and no closed tour exists for the 4×n board.Solomon GolombDouble and single loop in4x5 boardDouble loop in 4x8 board
21 Closed tours of few Boards 18x18 board5x6 8x x36x630x307x x85x x x3
23 Semi Magic Squares First semi-magic knight’s tour In each quadrant, the sum of the numbers equals 520 and each of therows and columns adds to 130The sum of the numbers in each 2x2 section is 130Even after so many number patterns it is called semi magic because the diagonals did not also addto 260.Total of 140 semi magic knight’s tours are found. But not even a single fully magic knight’s tour in 8x8 is possible
24 Knight’s tours and cryptography A cryptotour is a puzzle in which the 64 words or syllables of a verse areprinted on the squares of a chessboard and are to be read in the sequence ofa knight’s tour.
25 Knight’s tours and 3-D patterns Four polygons formed by 16 knight moves and their tessellation of the planeKnight’s tour tessellations can even be used to create beautiful 3-D patterns such as astersphaira hexastersphaira
26 References..Jelliss, George. ”Introducing Knight’s Tours.”“Knight’s Tours”- Ben Hill, Kevin Tostado“Closed Knight Tour on Rectangular Boards”- sciencedirect.comA. J. Schwenk, Which Rectangular Chessboards have a Knight.s Tour? Mathematics Magazine
Your consent to our cookies if you continue to use this website.