December 22, 2008

Handling illegal moves

It seems obvious that illegal moves are just that (illegal) and we shouldn’t worry about them.
For example, the PGN specification (section 8.2) is very clear saying:

PGN specification quote: "Because illegal moves are not real chess moves, they are not permitted in PGN movetext. They may appear in commentary, however. One would hope that illegal moves are relatively rare in games worthy of recording."

In other words an illegal move is not permitted at all and can invalidate the whole PGN. I’m not going to question what the PGN specification found impossible to solve. They stayed focused on chess and they did a pretty good job doing it.

Unfortunately, there are examples of actual games where illegal moves were played. One of those was pointed out by MostlyAverageJoe (on Wolfgang Heidenfeld vs. Kerin
(Note: As of 21-Oct-2009 the link doesn’t work anymore and the game is not available at – most probably deleted!)

The funny problem is that in this game white castled twice. White’s move 33.0-0-0 is illegal and any PGN complaint viewer will either ignore it or (much better) show it as illegal.

Fortunately, in this particular case PGN allows an elegant workaround as follows. I moved out the illegal section of the game into its own game (“Part: II”). It shows all the moves starting at white’s 33.0-0-0 and we can enjoy the rest of the game the way it was actually played.

UPDATE: A very recent example of handling a similar situation in an official tournament is the following game. I’m glad my understanding above is in unison with the way the game is presented in the provided PGN and on the official site (using ChessTheatre software).