PJ's Puzzles

A Daily Chess Puzzle

About Checkmate

Checkmate is a daily chess puzzle — arrange pieces on highlighted squares to deliver checkmate.

How it was made

This puzzle had an unusual origin.

A few years ago, I got really obsessed with puzzle boxes, especially the complex "sequential discovery" puzzles that are like an escape room in a box. I got it into my head that I wanted to design and build one, and I began thinking of physical puzzle mechanisms I could incorporate into my project.

At some point, my strange brain came up with the following puzzle as the grand finale:

As you solve the various puzzles and open compartments in the box, you find four chess pieces, each with some kind of key sticking out of the bottom of its base. On top of the box would be a chessboard with keyholes in the middle of certain squares.

You could try any of the keys in any of the keyholes, placing the chess pieces onto the board, but they would only unlock the box when the right keys were in the right locks. The correct arrangement would be the only one where the king was checkmated by the other three pieces.

Now, forget about how on earth you would begin making a lock mechanism like that. I did, almost immediately. I began to think about how I would figure out which squares to put the keyholes in. To do this, I essentially wrote the generator code that is now used to create the daily Checkmate games for this site.

I created a virtual chessboard with squares that could contain the pieces I wanted in the puzzle. I then created a set of functions to work out which squares are checked by the white pieces, which could be used to determine whether the king is checkmated.

From there... it is a bit crude and inefficient (but it works).

Step 1: The generator semi-randomly moves pieces around the board, trying to minimise the number of legal moves the king has, until he is checkmated. The squares containing the pieces are then marked as potential playable squares.

Step 2: The script tries the checkmate test on the 24 possible combinations of the four pieces in each marked square.

Step 3: If Step 2 found more than one way to checkmate the king, it is no good. Randomise the pieces and go back to Step 1.

Step 4: Otherwise, begin adding more playable squares at random, running the every-piece-on-every-square checkmate test each time to make sure there is still only one solution. If adding a square causes more solutions to pop up, remove it and try again.

Step 5: Once we reach a reasonable number of playable squares with one valid solution, output the result and exit. If it gets stuck too long in Step 4 adding and removing squares without reaching a good number, back to Step 1.

In the end, I liked the resulting puzzles more than I liked the idea of making a puzzle box, so I created a JavaScript UI to display and play the chess puzzles. I also added some alternate sets of white pieces for a bit of variety.

When I decided to make this site, I then ported it over to let the rest of the world play.