{"id":1193,"date":"2024-04-18T07:58:40","date_gmt":"2024-04-18T07:58:40","guid":{"rendered":"https:\/\/samhartburn.co.uk\/sh\/?p=1193"},"modified":"2024-04-18T07:58:41","modified_gmt":"2024-04-18T07:58:41","slug":"how-many-moves-can-a-knight-make","status":"publish","type":"post","link":"https:\/\/samhartburn.co.uk\/sh\/how-many-moves-can-a-knight-make\/","title":{"rendered":"How Many Moves can a Knight Make?"},"content":{"rendered":"\n<p>Imagine you&#8217;re a knight moving around on a chessboard, and you&#8217;re not allowed to visit any square that you&#8217;ve already been to. How quickly are you likely to get stuck?<\/p>\n\n\n\n<!--more-->\n\n\n\n<h5 class=\"wp-block-heading\">Chess<\/h5>\n\n\n\n<p>First, some definitions. If you&#8217;re familiar with chess you can skip this section.<\/p>\n\n\n\n<p><strong>Chess <\/strong>is a two-player game played on a <strong>chessboard<\/strong>, which is an 8 by 8 grid of black and white squares.<\/p>\n\n\n\n<p>A <strong>knight <\/strong>is one of the pieces used in a game of chess. It moves in an L-shape: two squares in one direction, followed by one square in another direction. So from any particular square, there are eight possible squares that a knight could move to (assuming that no move takes it off the edge of the board).<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"504\" src=\"https:\/\/samhartburn.co.uk\/sh\/wp-content\/uploads\/2024\/04\/8PossibleMoves-1024x504.png\" alt=\"Image shows the 8 possible moves a knight could make:\n2 right, 1 up\n2 up, 1 right\n2 up, 1 left\n2 left, 1 up\n2 left, 1 down\n2 down, 1 left\n2 down, 1 right\n2 right, 1 down\" class=\"wp-image-1194\" srcset=\"https:\/\/samhartburn.co.uk\/sh\/wp-content\/uploads\/2024\/04\/8PossibleMoves-1024x504.png 1024w, https:\/\/samhartburn.co.uk\/sh\/wp-content\/uploads\/2024\/04\/8PossibleMoves-300x148.png 300w, https:\/\/samhartburn.co.uk\/sh\/wp-content\/uploads\/2024\/04\/8PossibleMoves-768x378.png 768w, https:\/\/samhartburn.co.uk\/sh\/wp-content\/uploads\/2024\/04\/8PossibleMoves.png 1297w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<h5 class=\"wp-block-heading\">Knight&#8217;s tours<\/h5>\n\n\n\n<p>A <strong>knight&#8217;s tour<\/strong> is a path of knight&#8217;s moves that visits every square on the chessboard exactly once. There are billions of ways to do this! A few of them are shown below.<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"247\" src=\"https:\/\/samhartburn.co.uk\/sh\/wp-content\/uploads\/2024\/04\/4Tours-1024x247.png\" alt=\"Image shows four completed knight's tours\" class=\"wp-image-1196\" srcset=\"https:\/\/samhartburn.co.uk\/sh\/wp-content\/uploads\/2024\/04\/4Tours-1024x247.png 1024w, https:\/\/samhartburn.co.uk\/sh\/wp-content\/uploads\/2024\/04\/4Tours-300x72.png 300w, https:\/\/samhartburn.co.uk\/sh\/wp-content\/uploads\/2024\/04\/4Tours-768x185.png 768w, https:\/\/samhartburn.co.uk\/sh\/wp-content\/uploads\/2024\/04\/4Tours.png 1474w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p>If you choose a square to start from and try making moves at random, how likely do you think it is that you&#8217;ll find such a path?<\/p>\n\n\n\n<p>You can try this for yourself at <a href=\"https:\/\/maths-resources.com\/knights\/\" target=\"_blank\" rel=\"noopener\" title=\"\">https:\/\/maths-resources.com\/knights\/<\/a> &#8211; have a few tries and see how far around the board you can get before you get stuck.<\/p>\n\n\n\n<p>Of course, you probably weren&#8217;t making truly random moves &#8211; you might have put some thought into which move was most likely to be successful. Even then, you&#8217;re pretty unlikely to have found a path all the way around. (If you did, congratulations!)<\/p>\n\n\n\n<h5 class=\"wp-block-heading\">Randomly-generated knight&#8217;s moves<\/h5>\n\n\n\n<p>The graph below shows the results of one million attempts to find a knight&#8217;s tour by making moves at random. The number of squares visited is on the x-axis, and the number of times that was achieved is on the y-axis.<\/p>\n\n\n\n<figure class=\"wp-block-image aligncenter size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"854\" height=\"480\" src=\"https:\/\/samhartburn.co.uk\/sh\/wp-content\/uploads\/2024\/04\/ResultsBarChart_ManimCE_WhiteBackground.png\" alt=\"Bar chart showing Number of squares visited on x-axis (4 to 62) and Frequency on y-axis (0 to 45,000). Shows a skewed normal distribution with mode at about 38 squares.\" class=\"wp-image-1205\" srcset=\"https:\/\/samhartburn.co.uk\/sh\/wp-content\/uploads\/2024\/04\/ResultsBarChart_ManimCE_WhiteBackground.png 854w, https:\/\/samhartburn.co.uk\/sh\/wp-content\/uploads\/2024\/04\/ResultsBarChart_ManimCE_WhiteBackground-300x169.png 300w, https:\/\/samhartburn.co.uk\/sh\/wp-content\/uploads\/2024\/04\/ResultsBarChart_ManimCE_WhiteBackground-768x432.png 768w\" sizes=\"(max-width: 854px) 100vw, 854px\" \/><\/figure>\n\n\n\n<p>There are two striking things about this graph.<\/p>\n\n\n\n<p><strong>1: A full-length path (visiting all 64 squares) was never found.<\/strong><\/p>\n\n\n\n<p>In one million attempts, the longest path found visited only 62 of the 64 squares. Does this surprise you? To be honest, it didn&#8217;t surprise me very much. Although there are millions of paths that visit all 64 squares, there are millions more paths that don&#8217;t. The chance of getting all the way around the board by choosing random moves is very, very small.<\/p>\n\n\n\n<p><strong>2: There were some paths that only visited four squares.<\/strong><\/p>\n\n\n\n<p>This did surprise me! Four seems like a low number! Unless you were very unlucky, I expect you managed more than that when you tried it. This raises a question: where would you have to start from, and what moves would you have to make, to be stuck after only four moves? <\/p>\n\n\n\n<p>If you like, you could go back to <a href=\"https:\/\/maths-resources.com\/knights\/\" target=\"_blank\" rel=\"noopener\" title=\"\">https:\/\/maths-resources.com\/knights\/<\/a> and see if you can work it out.<\/p>\n\n\n\n<details class=\"wp-block-details is-layout-flow wp-block-details-is-layout-flow\"><summary>Or expand this section to see the answer.<\/summary>\n<p>One answer is shown below. Because of the symmetry in a chessboard there are seven other solutions, each starting one move away from a corner square and following a similar pattern.<\/p>\n\n\n\n<figure class=\"wp-block-image aligncenter size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"300\" height=\"301\" src=\"https:\/\/samhartburn.co.uk\/sh\/wp-content\/uploads\/2024\/04\/ThreeMovePath.jpg\" alt=\"Image showing the answer: Start one move away from a corner. Move to the space on the main diagonal through that corner, then back towards the corner, then into the corner. There are no further moves you can make from there.\" class=\"wp-image-1211\" srcset=\"https:\/\/samhartburn.co.uk\/sh\/wp-content\/uploads\/2024\/04\/ThreeMovePath.jpg 300w, https:\/\/samhartburn.co.uk\/sh\/wp-content\/uploads\/2024\/04\/ThreeMovePath-150x150.jpg 150w\" sizes=\"(max-width: 300px) 100vw, 300px\" \/><\/figure>\n<\/details>\n\n\n\n<h5 class=\"wp-block-heading\">More information<\/h5>\n\n\n\n<p>If you&#8217;ve enjoyed this article, you might also enjoy this video where I go into a little more detail, and sing a song about a knight looking for a knight&#8217;s tour.<\/p>\n\n\n\n<figure class=\"wp-block-embed is-type-video is-provider-youtube wp-block-embed-youtube wp-embed-aspect-16-9 wp-has-aspect-ratio\"><div class=\"wp-block-embed__wrapper\">\n<iframe loading=\"lazy\" title=\"More Than Nine Million Billion Ways (A maths song about knight&#039;s tours)\" width=\"500\" height=\"281\" src=\"https:\/\/www.youtube.com\/embed\/LXZIQ51W3Ns?feature=oembed\" frameborder=\"0\" allow=\"accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share\" referrerpolicy=\"strict-origin-when-cross-origin\" allowfullscreen><\/iframe>\n<\/div><\/figure>\n","protected":false},"excerpt":{"rendered":"<p>Imagine you&#8217;re a knight moving around on a chessboard, and you&#8217;re not allowed to visit any square that you&#8217;ve already been to. How quickly are you likely to get stuck?<\/p>\n","protected":false},"author":1,"featured_media":1219,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"saved_in_kubio":false,"footnotes":""},"categories":[109],"tags":[115,116,105],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/samhartburn.co.uk\/sh\/wp-json\/wp\/v2\/posts\/1193"}],"collection":[{"href":"https:\/\/samhartburn.co.uk\/sh\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/samhartburn.co.uk\/sh\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/samhartburn.co.uk\/sh\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/samhartburn.co.uk\/sh\/wp-json\/wp\/v2\/comments?post=1193"}],"version-history":[{"count":19,"href":"https:\/\/samhartburn.co.uk\/sh\/wp-json\/wp\/v2\/posts\/1193\/revisions"}],"predecessor-version":[{"id":1220,"href":"https:\/\/samhartburn.co.uk\/sh\/wp-json\/wp\/v2\/posts\/1193\/revisions\/1220"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/samhartburn.co.uk\/sh\/wp-json\/wp\/v2\/media\/1219"}],"wp:attachment":[{"href":"https:\/\/samhartburn.co.uk\/sh\/wp-json\/wp\/v2\/media?parent=1193"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/samhartburn.co.uk\/sh\/wp-json\/wp\/v2\/categories?post=1193"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/samhartburn.co.uk\/sh\/wp-json\/wp\/v2\/tags?post=1193"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}