Knight’s tour algorithm

9,596 views

Published on

Published in: Education
0 Comments
1 Like
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total views
9,596
On SlideShare
0
From Embeds
0
Number of Embeds
3
Actions
Shares
0
Downloads
159
Comments
0
Likes
1
Embeds 0
No embeds

No notes for slide

Knight’s tour algorithm

  1. 1. Knight’s Tour<br />Explanation and Algorithms<br />
  2. 2. GROUP MEMBERS<br />Hassan Tariq (2008-EE-180)<br />ZairHussainWani (2008-EE-178)<br />
  3. 3. Introduction<br />
  4. 4. What is ‘Knight’s Tour’?<br />Chess problem involving a knight<br />Start on a random square<br />Visit each square exactly ONCE according to rules<br />Tour called closed, if ending square is same as the starting<br />
  5. 5. Constraints<br />A closed knight’s tour is always possible on an <br />m x n chessboard, unless:<br /> m and n are both odd, but not 1 <br />m is either 1, 2 or 4<br /> m = 3, and n is either 4, 6 or 8<br />
  6. 6. m and n are both odd, but not 1<br />
  7. 7. Knight moves either from black square to white, or vice versa<br />In closed tour knight visits even squares<br />If m and n are odd i.e. 3x3, total squares are odd so tour doesn`t exist<br />
  8. 8. m = 1, 2, or 4; m and n are not both 1<br />
  9. 9. for m = 1 or 2, knight will not be able to reach every square<br />for m = 4, the alternate pattern of white and black square is not followed so tour not closed<br />
  10. 10. m = 3; n = 4, 6, or 8<br />
  11. 11. Have to be verified for each case<br />For n > 8, existence of closed tours can be proved by induction<br />
  12. 12. Algorithms<br />Neural Network Solutions<br />Warnsdorff’s Algorithm <br />
  13. 13. Neural Network Solutions<br />Every move represented by neuron<br />Each neuron initialized to be active or inactive <br />( 1 or 0 )<br />Each neuron having state function initialized to 0<br />
  14. 14. Neural Network Solutions (contd.)<br />Ut+1 (Ni,j) = Ut(Ni,j) +2 –  Vt(N)<br />NG(Ni,j)<br /> 1 Ut+1(Ni,j) > 3<br />Vt+1(Ni,j) = 0 Ut+1(Ni,j) < 0<br />Vt(Ni,j) otherwise<br />
  15. 15. Neural Network Solutions (contd.)<br />The network ALWAYS converge<br />Solution:<br /><ul><li> Closed knight’s tour
  16. 16. Series of two or more open tours</li></li></ul><li>Warnsdorff's Algorithm<br />Heuristic Method<br />Each move made to the square from which no. of subsequent moves is least<br />
  17. 17. Warnsdorff's Algorithm (contd.)<br />Set P to be a random initial position on the board<br />Mark the board at P with the move number "1" <br />For each move number from 2 to the number of squares on the board:<br /><ul><li>Let S be the set of positions accessible from the input position
  18. 18. Set P to be the position in S with minimum accessibility
  19. 19. Mark the board at P with the current move number</li></ul>Return the marked board – each square will be marked with the move number on which it is visited.<br />
  20. 20. Comparison<br />Neural networks<br />Warnsdorff's Algorithm <br />Complex algorithm (a lot of variables to be monitored)<br />Longer run-time<br />NOT always gives a complete tour<br />Simple algorithm<br />Linear run-time<br />Always gives a CLOSED tour<br />
  21. 21. Conclusion<br />WARNSDORFF’S ALGORITHM IS BETTER<br />

×