Blunder

This is mostly for chess players on Linux, but others may find it useful as well.

The software this uses and needs is:
* LAMP (Linux, Apache, MySQL, PHP)
* Crafty program for chess move evaluation and annotation (or equivalent)
* Xboard, or an equivalent (recommended, but optional)
* pgn2fen.exe program to convert PGN notation to FEN notation
* WINE Windows emulator to run pgn2fen.exe program


Most chess teachers say one of the methods to improve your game is to look over your games, especially your tournament games, and look for where you made mistakes. Part of this learning may be solely in the finding. However, not everyone has a grandmaster chess teacher looking over their games, who will point out blunders and missed opportunities that the student has missed.

Which is where my program comes in, which I call "Blunder". It is still in beta as everything has not been fully automated yet, but I have it working well enough for me. It definitely can be more automated, some of these steps are unnecessary. It is working though.


This is how I do it:

After finishing a game on FICS or ICC, I go on Xboard to File -> Save game.
When I am ready to start analyzing, I invoke Crafty on the command line. I then run the annotate command in the Crafty shell. The annotate command format is

annotate file.pgn color move points time

With file.pgn being the PGN file you saved with Xboard, with color being the color you were playing (w or b for white and black), with move being 1 since you are examining all moves.

You can adjust points to whatever you want, I usually do 0.5, but if you are a beginner 1 is fine. Points means what is the point difference between your move and what Crafty sees as the optimal move. For instance, if Crafty sees a move where you can safely take a pawn, but you miss it and do a normal move, the point difference is 1 as a pawn you could have had you didn't get. A point would be if you lose a pawn and didn't have to as well

Time is another variable you can decide. It is the maximum amount of time Crafty will consider each move. Usually you want Crafty to be looking at least 12 moves ahead, if not more. How this relates to seconds per move consideration depends on your processor. I usually have Crafty consider each move for 60-120 seconds. The more time you give it, the better advice Crafty will give you.

(I should note that Crafty 23.0 on Linux by default has the -DDEBUG compilation flag set by default. This is completely unnecessary and wastes over 85% of your processor time. You should disable this flag in your Makefile for Linux. Run a before and after gprof to see the difference).

Thus, within the crafty shell I might run
annotate Opponent-MyName.pgn b 1 0.5 120
This would annotate the PGN file Opponent-MyName.pgn, would only look at my (black's) moves, would start from move 1, score for any deviation over half a point (half a pawn) and would analyze each move for 120 minutes.

What I do after that is done (the analyzing time depends on the number of moves in the game times the number of seconds you tell it to analyze each move) is go through the annotated game, which is usually the name of the pgn file plus a .can suffix. In this case that would be Opponent-MyName.pgn.can. If the game was recent, I might remember a big blunder that I did. Usually what I look for is blunders and missed opportunities earlier in the game. If I make a blunder and lose a rook, and then make some other mistake, I am less concerned about the second mistake - once I lose a rook with no tradeoff, I assume I will probably be losing the game. Sometimes you don't see a blunder but a missed opportunity - a good move you could have made, but didn't. Sometimes I open another windows and replay the PGN visually, focusing on one or two moves that Crafty has noted.

At this point, I decide whether or not there are any moves I want to remember for posterity's sake. Sometimes the answer is no. Sometimes there is a blunder or missed opportunity I want to remember. Every once in a while, there is more than one blunder and/or missed opportunity I want to remember from a game.

That is when I convert my PGN from PGN to FEN format. I don't know any Linux command line tools that do this, perhaps I'll write one or collaborate on one. There is a Windows command line tool that does this though. Which I can run through WINE (WINE is a Linux Windows emulator). So I run pgn2en.exe via wine:

wine pgn2fen.exe Opponent-MyName.pgn

My PGN is now spit out in FEN format. The second field is the color (b or w), the sixth field is the move number in question. So let's say I want to remember move 19 when I am black. The FEN may be

r3kb1r/p4pp1/1pp1p2p/3pP1q1/2P3P1/2Q1PP2/PP1N3P/2KR3R b - - 0 19

So what I do is I go to my insertfens.html page on my web server and insert that FEN. I then go to my listfens.php page, which is sorted by move number. I look at the fullmove: 19 column and see the FEN. It has been given the id # of 64. Now I go to my insertblunders.html page. It asks for FEN # (the ID # I just got), the move I did (this is the move I did, in this case, a5), the move Crafty recommends (this is from the annotated can file), then I give the rating Crafty gave my move in points and the move Crafty gave its optimal move to, and the date of the match and hit Submit. The only catch is that if there was some three moves to mate move missed, Crafty's scores become astronomical. Usually, if I miss mating them, I give the moves a 100 point or so difference, if I make a blunder that leads to a checkmate of myself, I put a 200 point difference.

Now the blunder (or missed opportunity) is inserted. We are all done! Now we go to the listblunders.php page. It lists blunders in order of magnitude, with the biggest mistakes (200 points, we allowed them to mate us - 100 points, we miss a forced mate of them - 9 points, we lose a queen or miss an opportunity to snag their queen etc.) What is displayed is the FEN #, the date of the match, the point difference and a link to the board. I click through and see the board as I saw it when I originally was deciding the move, and at the bottom it say "black to move". I consider the board and let us say the first time I make the same mistake again in my head and decide a wrong move. I click on the board and it says "My move was: a5" (what it was in the original game, and in my second consideration as well). Then it says "a better move was: c5". I click the back button and look over the board again. I see now how vulnerable my c6 square was.

Weeks later I may review this again, perhaps still making the same mistake I made originally. After enough repetition, I begin to remember what the correct move was. I have several dozen blunders and missed opportunities in my database, and my faulty cognition is being replaced by these corrected memories, and perhaps better cognition. I remember to watch out for weak squares and double attacks - especially with one of the pieces attacked being my queen! Suddenly, when I am in similar situations, I deal with this correctly now. I begin to play better and win more games.

The Blunder program has more steps than is ultimately necessary, but compared to the earlier alternative, it saves a lot of time. In the future, this program will probably be simplified and automated more.

It is released by me under the GNU Public License, Version 3.