
    
        
        
        
                
        
        
        
                
        
        
        
                
        
        
        
                
        
        
        
                
        
        
        
            
{"version":"https:\/\/jsonfeed.org\/version\/1","title":"mathspp.com feed","home_page_url":"https:\/\/mathspp.com\/blog\/tags\/chess","feed_url":"https:\/\/mathspp.com\/blog\/tags\/chess.json","description":"Stay up-to-date with the articles on mathematics and programming that get published to mathspp.com.","author":{"name":"Rodrigo Gir\u00e3o Serr\u00e3o"},"items":[{"title":"Elo rating system simulation","date_published":"2022-01-25T00:00:00+01:00","id":"https:\/\/mathspp.com\/blog\/elo-rating-system-simulation","url":"https:\/\/mathspp.com\/blog\/elo-rating-system-simulation","content_html":"<p>Join me as I create a simulation that tries to test an Elo-based rating system for quizzes.<\/p>\n\n<figure class=\"image-caption\"><img title=\"Screenshot of the simulation web app.\" alt=\"Screenshot of a Python Streamlit web app.\" src=\"\/images\/a\/1\/3\/6\/2\/a1362e99125e7c0764cc35a8e9d02d4a224f3260-thumbnail.webp\"><figcaption class=\"\">Screenshot of the simulation web app.<\/figcaption><\/figure><h2 id=\"introduction\">Introduction<a href=\"#introduction\" class=\"toc-anchor after\" data-anchor-icon=\"#\" aria-label=\"Anchor\"><\/a><\/h2>\n<p>In this article, I will tell you about a simulation that I built.\nThis simulation is built around a rating system that is based off of the <a href=\"https:\/\/en.wikipedia.org\/wiki\/Elo_rating_system\" target=\"_blank\" rel=\"nofollow noopener noreferrer\" class=\"external-link no-image\">Elo rating system<\/a>,\nand I will use <a href=\"\/blog\/til\/026\">Streamlit<\/a> to build the app that will control the simulation.\nThis will also make it easier to share the simulation with others.<\/p>\n<p>In short, I'll be walking you through the process of writing <a href=\"https:\/\/github.com\/mathspp\/elo-simulation\" target=\"_blank\" rel=\"nofollow noopener noreferrer\" class=\"external-link no-image\">this code<\/a> and,\nin the end, the code I linked to in that GitHub repository is going to be used\nto host the Streamlit web app that you can play with live, <a href=\"https:\/\/share.streamlit.io\/mathspp\/elo-simulation\/main\/simulation.py\" target=\"_blank\" rel=\"nofollow noopener noreferrer\" class=\"external-link no-image\">here<\/a>.<\/p>\n<p>The screenshot above also refers to the same Streamlit web app.<\/p>\n<h2 id=\"elo-based-rating-system-for-quizzes\">Elo-based rating system for quizzes<a href=\"#elo-based-rating-system-for-quizzes\" class=\"toc-anchor after\" data-anchor-icon=\"#\" aria-label=\"Anchor\"><\/a><\/h2>\n<p>What I'm trying to do is design a decent rating system for a quiz app.\nThe idea is that the quiz questions will have a rating,\nand so will the &ldquo;players&rdquo;: the people answering the quiz.<\/p>\n<p>Every time a person answers a question, their rating gets adjusted depending on whether they answered the question correctly.\nSimilarly, the question's rating gets updated.\nIf the player answers correctly, the player's rating goes up and the question's goes down.\nIf the player answers incorrectly, the ratings change the other way around.<\/p>\n<p>So, how can we build such a system?<\/p>\n<p>The <a href=\"https:\/\/en.wikipedia.org\/wiki\/Elo_rating_system\" target=\"_blank\" rel=\"nofollow noopener noreferrer\" class=\"external-link no-image\">Elo rating system<\/a> is a system that attributes a numeric rating to players,\nin order to determine the relative skill of the players.\nThe Elo rating is probably best known for being the rating used in chess.<\/p>\n<p>I have seen the website chess.com use an Elo-like system for their chess problems:\nyou play the problem and, if you get it right, your problem-solving rating increases;\nat the same time, the rating of the problem decreases.\nIf you get it wrong, vice-versa.\nI want to try and mimic this functionality.<\/p>\n<p>The purpose of building a simple simulation is to try and see if my assumptions\nabout the rating system work, or if the system will go bonkers when used in real life!\nOf course, the simulation will represent a simplification of reality:<\/p>\n<ul><li>if the simulation shows bad behaviour, then the system probably won't work in real life; but<\/li>\n<li>if the simulation shows good behaviour, then <em>maybe<\/em> the system will work in real life.<\/li>\n<\/ul><h2 id=\"updating-the-rating\">Updating the rating<a href=\"#updating-the-rating\" class=\"toc-anchor after\" data-anchor-icon=\"#\" aria-label=\"Anchor\"><\/a><\/h2>\n<p>The key thing that I need is the formula to update the rating when two players face each other off.\nIf we scroll the Wikipedia article to the section that mentions the mathematical details,\nwe get what we need.<\/p>\n<p>Suppose that players <span class=\"mathjax mathjax--inline\">\\(A\\)<\/span> and <span class=\"mathjax mathjax--inline\">\\(B\\)<\/span> have ratings <span class=\"mathjax mathjax--inline\">\\(R_A\\)<\/span> and <span class=\"mathjax mathjax--inline\">\\(R_B\\)<\/span>, respectively.\nThe Elo rating system determines how well it <em>thinks<\/em> each player should perform,\nwhen compared to the other player.\nIn other words, the ratings <span class=\"mathjax mathjax--inline\">\\(R_A\\)<\/span> and <span class=\"mathjax mathjax--inline\">\\(R_B\\)<\/span> don't really say how good &ndash; or how bad &ndash;\neach player is; the ratings only say...<\/p>","summary":"Join me as I create a simulation that tries to test an Elo-based rating system for quizzes.","date_modified":"2025-07-23T16:49:02+02:00","tags":["chess","mathematics","programming","python","simulation","streamlit"],"image":"\/user\/pages\/02.blog\/elo-rating-system-simulation\/thumbnail.webp"},{"title":"Problem #052 \u2013 chessboard domino","date_published":"2021-12-29T00:00:00+01:00","id":"https:\/\/mathspp.com\/blog\/problems\/chessboard-domino","url":"https:\/\/mathspp.com\/blog\/problems\/chessboard-domino","content_html":"<p>Can you tile a chessboard with two missing squares?<\/p>\n\n<figure class=\"image-caption\"><img title=\"A chessboard with two domino tiles on top of it.\" alt=\"\" src=\"\/images\/2\/e\/d\/2\/6\/2ed2670aa39e389f82f4a696e6dda2886f2d26c4-thumbnail.webp\"><figcaption class=\"\">A chessboard with two domino tiles on top of it.<\/figcaption><\/figure>\n<h2 id=\"problem-statement\">Problem statement<a href=\"#problem-statement\" class=\"toc-anchor after\" data-anchor-icon=\"#\" aria-label=\"Anchor\"><\/a><\/h2>\n<p>If you remove two opposite corners of a chessboard,\ncan you still tile it with 2 x 1 rectangles?<\/p>\n<p>In other words, can you cover a whole chessboard with 2 x 1 domino tiles while leaving two opposite corners uncovered and without overlapping domino tiles?<\/p>\n<h2 id=\"solvers\">Solvers<a href=\"#solvers\" class=\"toc-anchor after\" data-anchor-icon=\"#\" aria-label=\"Anchor\"><\/a><\/h2>\n<p>Congratulations to the ones that solved this problem correctly and, in particular, to the ones\nwho sent me their correct solutions:<\/p>\n<ul>\n<li>David H., Taiwan;<\/li>\n<li>Kees de L., Netherlands;<\/li>\n<\/ul>\n<p>Know how to solve this?<\/p>\n<p>Join the list of solvers by <a href=\"mailto:rodrigo@mathspp.com?subject=Solution%20to%20Problem%20#052%20%E2%80%93%20chessboard%20domino\" class=\"mailto\">emailing me<\/a> your solution!<\/p>\n<h2 id=\"solution\">Solution<a href=\"#solution\" class=\"toc-anchor after\" data-anchor-icon=\"#\" aria-label=\"Anchor\"><\/a><\/h2>\n<p>It is <em>impossible<\/em> to do this and the proof follows.<\/p>\n<p>We start by realising that whenever we place a 2x1 domino tile on a chessboard, we always cover two squares of opposite colours, regardless of where we place the domino tile and regardless of its orientation.<\/p>\n<p>Now, consider the colours of the squares of a chessboard with two opposite corners removed.\nOpposite corners are of the same colour, so if we remove two white corners, the chessboard remains with 30 white squares and 32 black squares.\nWhenever we place a domino tile on the board, each of the two quantities decreases by 1.\nSo, after we place 30 domino tiles, there will be 0 white squares left to cover and 2 black squares, which cannot be covered by a single domino tile.<\/p>\n<p><a href=\"\/subscribe\">Don't forget to subscribe to the newsletter<\/a> to get bi-weekly\nproblems sent straight to your inbox.<\/p>","summary":"Can you tile a chessboard with two missing squares?","date_modified":"2025-07-23T16:49:02+02:00","tags":["chess","combinatorics","mathematics"],"image":"\/user\/pages\/02.blog\/03.problems\/p052-tiling-a-chessboard\/thumbnail.webp"},{"title":"Problem #051 \u2013 queens and knights","date_published":"2021-12-12T00:00:00+01:00","id":"https:\/\/mathspp.com\/blog\/problems\/queens-and-knights","url":"https:\/\/mathspp.com\/blog\/problems\/queens-and-knights","content_html":"<p>How many queens and knights can you place on a chessboard?<\/p>\n\n<figure class=\"image-caption\"><img title=\"Photo by \u1d0a\u1d00\u1d04\u029c\u028f\u1d0d \u1d0d\u026a\u1d04\u029c\u1d00\u029f on Unsplash.\" alt=\"A white chess queen and black chess knight's silhouettes against the sun.\" src=\"\/images\/0\/a\/8\/0\/9\/0a809b3a31933fb1cf2d8b2980b14846886cc54d-thumbnail.webp\"><figcaption class=\"\">Photo by \u1d0a\u1d00\u1d04\u029c\u028f\u1d0d \u1d0d\u026a\u1d04\u029c\u1d00\u029f on Unsplash.<\/figcaption><\/figure>\n<h2 id=\"problem-statement\">Problem statement<a href=\"#problem-statement\" class=\"toc-anchor after\" data-anchor-icon=\"#\" aria-label=\"Anchor\"><\/a><\/h2>\n<p>This is a harder variant of the <a href=\"\/blog\/problems\/8-queens\">8 queens<\/a> problem.\nAs a warm-up for <em>this<\/em> problem, consider solving that one first!<\/p>\n<p>For the \u201cqueens and knights\u201d problem,\nyou want to place as many queens and knights, as possible, on a chessboard.\nHowever, queens and knights must be placed in equal numbers,\nand no piece can attack any other piece.<\/p>\n<p>While you are at it, can you do it in multiple ways?<\/p>\n<p>For reference, here is a picture showing what squares a queen attacks:<\/p>\n<figure class=\"image-caption\"><img title=\"Squares under attack by a queen.\" alt=\"Chessboard with a queen and the squares under attack.\" src=\"\/user\/pages\/02.blog\/03.problems\/p051-queens-and-knights\/_queen_attack.webp\"><figcaption class=\"\">Squares under attack by a queen.<\/figcaption><\/figure>\n<p>Similarly, here is a picture showing what squares a knight attacks:<\/p>\n<figure class=\"image-caption\"><img title=\"Squares under attack by a knight.\" alt=\"Chessboard with a knight and the squares under attack.\" src=\"\/user\/pages\/02.blog\/03.problems\/p051-queens-and-knights\/_knight_attack.webp\"><figcaption class=\"\">Squares under attack by a knight.<\/figcaption><\/figure>\n<div class=\"notices blue\">\n<p>Give it some thought!<\/p>\n<\/div>\n<p>If you need any clarification whatsoever, feel free to ask in the comment section below.<\/p>\n<p>This problem was brought to my attention by the late <a href=\"https:\/\/rogerhui.rip\/\" target=\"_blank\" rel=\"nofollow noopener noreferrer\" class=\"external-link no-image\">Roger Hui<\/a>,\nso let my sharing this problem be a small tribute to him.<\/p>\n<h2 id=\"solvers\">Solvers<a href=\"#solvers\" class=\"toc-anchor after\" data-anchor-icon=\"#\" aria-label=\"Anchor\"><\/a><\/h2>\n<p>Congratulations to the ones that solved this problem correctly and, in particular, to the ones\nwho sent me their correct solutions:<\/p>\n<ul>\n<li>David H., Taiwan;<\/li>\n<\/ul>\n<p>Know how to solve this?<\/p>\n<p>Join the list of solvers by <a href=\"mailto:rodrigo@mathspp.com?subject=Solution%20to%20Problem%20#051%20%E2%80%93%20queens%20and%20knights\" class=\"mailto\">emailing me<\/a> your solution!<\/p>\n<h2 id=\"solution\">Solution<a href=\"#solution\" class=\"toc-anchor after\" data-anchor-icon=\"#\" aria-label=\"Anchor\"><\/a><\/h2>\n<p>We can start by showing that it is impossible to have 6 queens and 6 knights on the board.<\/p>\n<p>To place 6 queens on a board, they have to be in 6 different rows and 6 different columns, which means they leave a maximum of 4 squares (2 rows times 2 columns) free.\nWe cannot fit 6 knights into 4 squares.<\/p>\n<p>By finding a configuration with 5 queens and 5 knights, we prove that the maximum is 5, which is what the figure shows:<\/p>\n<p><img alt=\"\" src=\"\/user\/pages\/02.blog\/03.problems\/p051-queens-and-knights\/_solution.webp\"><\/p>\n<p>In chess notation, we could place 5 queens at g1, b2, f3, c4, and a5, and the knights at h6, h7, e7, d7, and e8.<\/p>\n<p><a href=\"\/subscribe\">Don't forget to subscribe to the newsletter<\/a> to get bi-weekly\nproblems sent straight to your inbox.<\/p>","summary":"How many queens and knights can you place on a chessboard?","date_modified":"2025-07-23T16:49:02+02:00","tags":["chess","combinatorics","mathematics"],"image":"\/user\/pages\/02.blog\/03.problems\/p051-queens-and-knights\/thumbnail.webp"},{"title":"Problem #050 \u2013 8 queens","date_published":"2021-11-28T00:00:00+01:00","id":"https:\/\/mathspp.com\/blog\/problems\/8-queens","url":"https:\/\/mathspp.com\/blog\/problems\/8-queens","content_html":"<p>In how many ways can you place 8 queens on a chessboard?<\/p>\n\n<figure class=\"image-caption\"><img title=\"Chess queen and attacked positions on a photo by Nick Fewings on Unsplash.\" alt=\"A chessboard seen from above with a queen in the centre and lines showing the positions under attack.\" src=\"\/images\/c\/f\/3\/d\/3\/cf3d375c82a31695ad42e5325327bc9a88631cd0-thumbnail.webp\"><figcaption class=\"\">Chess queen and attacked positions on a photo by Nick Fewings on Unsplash.<\/figcaption><\/figure>\n<h2 id=\"problem-statement\">Problem statement<a href=\"#problem-statement\" class=\"toc-anchor after\" data-anchor-icon=\"#\" aria-label=\"Anchor\"><\/a><\/h2>\n<p>The image above shows you what positions a single queen attacks on a chessboard:\nall positions in the same vertical, horizontal, and diagonal lines.<\/p>\n<p>Your job is to place 8 queens on a chessboard, so that no two queens attack each other.\n(In how many different ways can you do this?)<\/p>\n<p>Is this too easy?\nDon't worry, the next one will be a harder variant of this puzzle.<\/p>\n<div class=\"notices blue\">\n<p>Give it some thought!<\/p>\n<\/div>\n<p>If you need any clarification whatsoever, feel free to ask in the comment section below.<\/p>\n<h2 id=\"solvers\">Solvers<a href=\"#solvers\" class=\"toc-anchor after\" data-anchor-icon=\"#\" aria-label=\"Anchor\"><\/a><\/h2>\n<p>Congratulations to the ones that solved this problem correctly and, in particular, to the ones\nwho sent me their correct solutions:<\/p>\n<ul>\n<li>David H., Taiwan;<\/li>\n<li>Kees de L., Netherlands;<\/li>\n<li>B. Praveen R., India;<\/li>\n<li>Kishan M., India;<\/li>\n<li>Mario V., Guatemala;<\/li>\n<li>Pavel D., Czech Republic;<\/li>\n<\/ul>\n<p>Know how to solve this?<\/p>\n<p>Join the list of solvers by <a href=\"mailto:rodrigo@mathspp.com?subject=Solution%20to%20Problem%20#050%20%E2%80%93%208%20queens\" class=\"mailto\">emailing me<\/a> your solution!<\/p>\n<h2 id=\"solution\">Solution<a href=\"#solution\" class=\"toc-anchor after\" data-anchor-icon=\"#\" aria-label=\"Anchor\"><\/a><\/h2>\n<p>Here is an example placement of 8 queens on a chessboard:<\/p>\n<figure class=\"image-caption\"><img title=\"Eight, non-attacking queens.\" alt=\"Queens in positions h7, g5, f3, e1, d6, c8, b2, a4.\" src=\"\/user\/pages\/02.blog\/03.problems\/p050-8-queens\/_solution.webp\"><figcaption class=\"\">Eight, non-attacking queens.<\/figcaption><\/figure>\n<p>This is a neat little puzzle, but I can't offer a better solution other than \u201cdo it by trial and error\u201d.<\/p>\n<p>As for the total number of solutions, there are 92.\nAgain, sadly I don't know of a nice way to compute that by hand,\nbut I can show you a Python program that computes all the solutions:<\/p>\n<pre><code class=\"language-py\">&gt;&gt;&gt; from itertools import permutations\n&gt;&gt;&gt; for queens in permutations(range(8)):\n...     diags = {r - c for r, c in enumerate(queens)}\n...     antidiags = {r + c for r, c in enumerate(queens)}\n...     if len(diags) == len(antidiags) == 8:\n...         # print(list(enumerate(queens)))\n...         c += 1\n...\n&gt;&gt;&gt; c\n92<\/code><\/pre>\n<p>This is a Python snippet that solves this problem.\nBy using <code>itertools.permutations<\/code>, we manage to get all possible queen placements\nwhere no queen attacks another queen horizontally or vertically.\nThen, we are left with checking for the diagonals.<\/p>\n<p>For the diagonals (and representing both rows and columns as integers),\nwe have that each diagonal has an invariant.\nFor one set of diagonals, that invariant is the sum of the two coordinates,\nand for the other set of diagonals, it's the difference between the two coordinates.<\/p>\n<p>For example, letting the letters \u201cA\u201d through \u201cH\u201d represent the integers 1 through 8,\nhere is an image that shows how, along one diagonal,\nthe sum of the two coordinates is always 10 and, along another diagonal,\nthe difference of the two coordinates is always -2:<\/p>\n<figure class=\"image-caption\"><img title=\"Two diagonals, and their invariants, highlighted.\" alt=\"A chessboard with two highlighted diagonals showing their invariants.\" src=\"\/user\/pages\/02.blog\/03.problems\/p050-8-queens\/_diagonals.webp\"><figcaption class=\"\">Two diagonals, and their invariants, highlighted.<\/figcaption><\/figure>\n<p>Therefore, we can just check if all the invariants are different because,\nif they are, that's because the queens are not attacking each other diagonally.<\/p>\n<p>Now, was this easy?\nI have a <a href=\"\/blog\/problems\/queens-and-knights\">similar, but harder problem<\/a> waiting for you.<\/p>\n<p><a href=\"\/subscribe\">Don't forget to subscribe to the newsletter<\/a> to get bi-weekly\nproblems sent straight to your inbox.<\/p>","summary":"In how many ways can you place 8 queens on a chessboard?","date_modified":"2025-07-23T16:49:02+02:00","tags":["chess","combinatorics","mathematics"],"image":"\/user\/pages\/02.blog\/03.problems\/p050-8-queens\/thumbnail.webp"},{"title":"TIL #002 \u2013 fake chess AI","date_published":"2021-09-16T00:00:00+02:00","id":"https:\/\/mathspp.com\/blog\/til\/002","url":"https:\/\/mathspp.com\/blog\/til\/002","content_html":"<p>Today I learned about a fake chess-playing AI from the 1700s.<\/p>\n\n<script async src=\"https:\/\/platform.twitter.com\/widgets.js\" charset=\"utf-8\"><\/script>\n<figure class=\"image-caption\"><img title=\"A copper engraving of the Turk, from the Wikipedia article.\" alt=\"\" src=\"\/images\/5\/8\/7\/a\/6\/587a6e8a3a5b316218ff0deab4746585426570b8-thumbnail.png\"><figcaption class=\"\">A copper engraving of the Turk, from the Wikipedia article.<\/figcaption><\/figure>\n<h2 id=\"mechanical-turk\">Mechanical Turk<a href=\"#mechanical-turk\" class=\"toc-anchor after\" data-anchor-icon=\"#\" aria-label=\"Anchor\"><\/a><\/h2>\n<p>The <a href=\"https:\/\/en.wikipedia.org\/wiki\/Mechanical_Turk\" target=\"_blank\" rel=\"nofollow noopener noreferrer\" class=\"external-link no-image\">Mechanical Turk<\/a> was a device that was said to be an automaton capable of playing chess,\ndefeating many players around the world.\nLater on, it was found that the machine was just a hoax,\nas it hid a seasoned chess player that could then operate the machine.<\/p>\n<p>I learned this from a tweet I saw, that jokingly asked if the Mechanical Turk was the first AI in the world:<\/p>\n<blockquote class=\"twitter-tweet\">\n<p lang=\"en\" dir=\"ltr\">Interesting!<br><br>Also is this the world's first \"AI\"?<a href=\"https:\/\/t.co\/bqPOypCnFU\" target=\"_blank\" rel=\"nofollow noopener noreferrer\" class=\"external-link no-image\">https:\/\/t.co\/bqPOypCnFU<\/a><\/p>\u2014 Nat Miletic (@natmiletic) <a href=\"https:\/\/twitter.com\/natmiletic\/status\/1438564131859157003?ref_src=twsrc%5Etfw\" target=\"_blank\" rel=\"nofollow noopener noreferrer\" class=\"external-link no-image\">September 16, 2021<\/a>\n<\/blockquote>\n<p>Reading about this reminded me of <a href=\"https:\/\/en.wikipedia.org\/wiki\/Deep_Blue_(chess_computer)\" target=\"_blank\" rel=\"nofollow noopener noreferrer\" class=\"external-link no-image\">Deep Blue<\/a>,\nthe first computer to beat the reigning world champion in a chess game\nand a chess match, using the regular time constraints from competitions.<\/p>\n<p>Deep Blue was from IBM and it was in the year of 1997 (the year I was born!)\nthat it beat Kasparov, the then-world champion.<\/p>\n<p>If you are into machine learning and all these cool things,\nyou might also be interested in googling <a href=\"https:\/\/stockfishchess.org\/\" target=\"_blank\" rel=\"nofollow noopener noreferrer\" class=\"external-link no-image\">Stockfish<\/a> (a powerful chess engine)\nor <a href=\"https:\/\/deepmind.com\/research\/case-studies\/alphago-the-story-so-far\" target=\"_blank\" rel=\"nofollow noopener noreferrer\" class=\"external-link no-image\">AlphaGo<\/a> (arguably the best Go player in the world \u2013 even better than professional humans)\nfrom <a href=\"https:\/\/deepmind.com\/\" target=\"_blank\" rel=\"nofollow noopener noreferrer\" class=\"external-link no-image\">DeepMind<\/a>.<\/p>\n<p>As far as my recollection goes, DeepMind has been doing some amazing\nwork when it comes to building AIs that play \u201cdifficult\u201d games.\nI don't remember their differences,\nbut there's <em>at least<\/em> AlphaGo, AlphaZero, and AlphaGo Zero...<\/p>\n<p>Thinking about this gets me all hyped up about reinforcement learning!\nI've written about it in the past (in my old blog, I have to revive those articles)...\nMaybe I should write about it again soon!<\/p>\n<p><a href=\"\/subscribe\">Stay tuned!<\/a><\/p>","summary":"Today I learned about a fake chess-playing AI from the 1700s.","date_modified":"2025-07-23T16:49:02+02:00","tags":["chess","machine learning"],"image":"\/user\/pages\/02.blog\/04.til\/002.fake-chess-ai\/thumbnail.png"},{"title":"Problem #025 - knight&#039;s tour","date_published":"2020-12-13T00:00:00+01:00","id":"https:\/\/mathspp.com\/blog\/problems\/knights-tour","url":"https:\/\/mathspp.com\/blog\/problems\/knights-tour","content_html":"<p>Alice and Bob sit down, face to face, with a chessboard in front of them.\nThey are going to play a little game, but this game only has a single knight...\nWho will win?<\/p>\n\n<figure class=\"image-caption\"><img title=\"Photo by Piotr Makowski on Unsplash\" alt=\"A chess knight\" src=\"\/user\/pages\/02.blog\/03.problems\/p025-knights-tour\/thumbnail.jpg\"><figcaption class=\"\">Photo by Piotr Makowski on Unsplash<\/figcaption><\/figure><h2 id=\"problem-statement\">Problem statement<a href=\"#problem-statement\" class=\"toc-anchor after\" data-anchor-icon=\"#\" aria-label=\"Anchor\"><\/a><\/h2>\n<p>Alice and Bob will play a special game of &ldquo;chess&rdquo;.\nAlice will take the knight and place it in some square of the chessboard, any square she likes.<\/p>\n<p><img alt=\"Chessboard with a knight\" src=\"\/user\/pages\/02.blog\/03.problems\/p025-knights-tour\/_chessboard_01.webp\"><\/p>\n<p>Then, Bob will take the knight and move it (according to chess rules) to a square of his choosing.<\/p>\n<p><img alt=\"Chessboard after another move\" src=\"\/user\/pages\/02.blog\/03.problems\/p025-knights-tour\/_chessboard_02.webp\"><\/p>\n<p>Then it's Alice's turn to do the same, and they will alternate moving the knight.\nThere is only a catch:<\/p>\n<blockquote>\n<p>They <strong>cannot<\/strong> move the knight to a position that has already been visited by the knight.<\/p>\n<\/blockquote>\n<p>In the example image below, the knight cannot be moved one row down and two columns right, as that is the place the knight started at.<\/p>\n<p><img alt=\"Same chessboard with some squares already visited\" src=\"\/user\/pages\/02.blog\/03.problems\/p025-knights-tour\/_chessboard_03.webp\"><\/p>\n<p>Thus, the player who cannot make a valid move loses.<\/p>\n<p>Can any of them guarantee a win? Who? How?<\/p>\n<div class=\"notices blue\">\n<p>Give it some thought...<\/p>\n<\/div>\n<p>If you want, you can try playing the game against the computer <a href=\"https:\/\/mathspp.com\/games\/knights-tour\">here<\/a>.<\/p>\n<p>If you need any clarification whatsoever, feel free to ask in the comment section below.<\/p>\n<p>This problem was posed to me by a university colleague that plays a lot of chess!<\/p>\n<h2 id=\"solution\">Solution<a href=\"#solution\" class=\"toc-anchor after\" data-anchor-icon=\"#\" aria-label=\"Anchor\"><\/a><\/h2>\n<p>We will show that Bob (the second player) can always win the game.\nTo do that, we will follow a very simple strategy: we show that,\nregardless of what Alice plays, Bob <em>always<\/em> has a legal move he can make.\nIf Bob can <em>always<\/em> play something, and if the game is always a finite game\n(because there are <span class=\"mathjax mathjax--inline\">\\(64\\)<\/span> squares in a chessboard, the game can never last\nfor longer than <span class=\"mathjax mathjax--inline\">\\(64\\)<\/span> moves), then Alice is sure to lose.<\/p>\n<p>The first thing we do is consider a division of the chessboard\ninto <span class=\"mathjax mathjax--inline\">\\(8\\)<\/span> rectangles with dimensions <span class=\"mathjax mathjax--inline\">\\(4 \\times 2\\)<\/span>, like the figure below shows.<\/p>\n<p><img alt=\"A chessboard divided into $8$ rectangles of dimensions $4 \\times 2$.\" src=\"\/user\/pages\/02.blog\/03.problems\/p025-knights-tour\/_sol_chessboard_01.webp\"><\/p>\n<p>Notice that all squares of the chessboard lie inside one of those rectangles and,\n<em>most importantly<\/em>, notice that each square is such that the knight only has a legal move that starts and ends in the same <span class=\"mathjax mathjax--inline\">\\(4 \\times 2\\)<\/span> rectangle.<\/p>\n<p>As an example, take a knight that is as central in the chessboard as possible,\nin the fourth row from the top and the fourth column from the left.\nSuch a knight has <span class=\"mathjax mathjax--inline\">\\(8\\)<\/span> possible moves, but only one lands in the same rectangle as the\none the knight is standing one.\nThis is shown in the next figure, with the slightly transparent knights representing\npossible moves and with a different frame colour for the rectangle that holds the\ninitial knight position and the only move that lands in that same rectangle.<\/p>\n<p><img alt=\"A chessboard with a knight in position d5 and the legal knight moves highlighted.\" src=\"\/user\/pages\/02.blog\/03.problems\/p025-knights-tour\/_sol_chessboard_02.webp\"><\/p>\n<p>This can be seen as a very well established pattern, as each rectangle is the same.\nIn the next figure we schematise the pairs of squares, within a rectangle, that\ncan be travelled to and from by a chess knight.\nIn...<\/p>","summary":"This problem pits Alice against Bob in a little game that takes place in a chessboard.","date_modified":"2026-05-01T21:10:36+02:00","tags":["chess","game theory"],"image":"\/user\/pages\/02.blog\/03.problems\/p025-knights-tour\/thumbnail.jpg"}]}
