title: Tactics chess
description: a chess puzzle generator and solver interface
Tactics training is such an essential part of chess if you want to improve. So much so that I bought a premium chess.com subscription mainly for the unlimited tactics they give. But then I thought, why not do my own and have unlimited tactics to practice on? See that cluster from laptops a couple of posts ago? well that is the chess engine cluster that I’m using to generate tactics training puzzles such as this:
white to play and get a good position with blacks king wondering around the board
So how are tactics like these generated? Find the positions for tactical opportunities is actually rather simple. You get some game PGN’s, and feed them into a chess engine like stockfish, and mark the position where the engine evaluation goes from a draw-ish position to a material advantage for one side. For example consider the board state
the evaluation stock fish has given for this position is 34cp (0.34 pawns). But in the game black made the mistake of playing e5 which tilted the evaluation of the position to 338cp (3.38 pawns) in whites favour. This means that white has the opportunity to gain a substantial advantage with a certain move. That’s what’s asked of the player during the tactics training session, find this move and the sequence of moves that come after it to hold the advantage. And that’s the hard part. How do you know when to terminate the sequence of moves for the puzzle. If you just let the player play 1 move, you have no way of knowing if the player actually saw the correct sequence that leads to an advantageous position or if it was just a lucky guess. It’s not satisfying to the player just to play one move and not follow through.
Code: Select all
`r1b1r3/1p1nqpkp/p3pnp1/3p2N1/3P3Q/2NBP3/PP3PPP/3R1RK1 b - - 13 15`
The chess engine evaluation line actually gives you the lines that it considers good, so that’s a big help. You just need to have the player play along these lines, but for how many moves? A tactical position may result in an advantage in 2 moves or 5 moves after a long combination. What I have found that works nicely are the following conditions for termination:
* Go a maximum of 6 moves (12 plies) deep during searching. 6 moves deep is very challenging even for masters of the game.
* if the last move was not a capture
* if the last move was not a check
* if the last move was not a mate in X move
* if the opponent would pass, a capture would not be made
Checking for these conditions after every candidate move leads to some pretty decent puzzles.
Here is my poor-mans cluster that crunched all the games to generate the tactics