Visualize Move, Protection and Threat Status in Chess

Chess Inspector - Mid-gametl;dr:

When I was a kid, my younger brother became a chess master and would regularly thrash me in the game.  Invariably this seemed to be because I would do something dumb like leaving my queen threatened and unattended.

As with many budding CS students, I devised my own chess playing program, but in this case, it was for the purpose of making me a better player.  In fact I devised a chess program in every language I decided to learn…

Cut to the present and check out my Dancer web-app written in Perl, at the above URL.  Even though its a “web-app” it is most useful (to me) to run on my local machine to study games, rather than on a public server.  But it is built to work in any environment!

Each move may be shown, forward or reverse, with handy “tape recorder” buttons.

Here are the working parts:

  1. The excellent Chess::Rep module represents chess positions and generates a list of legal moves for a piece.  This module allows me to compute every possible move for every piece of a chess game.
  2. My handy Chess::Rep::Coverage module computes the potential energy of a chessboard, given by move, threat and protection status.  This is a very tedious process.
  3. The Chess::Pgn module for reading and parsing chess “PGN” game file “meta-data” – result, event, date, etc.
  4. Perl Dancer for UI display and control.

OK here is the Dancer route defining the Chess::Inspector single page application:

The $results variable holds all the Chess::Rep::Coverage details for display – game, player and cell states.

Here is the code, buried under the Dancer coverage() routine, that sets the state for a given cell and appends it to the current row:

Here is the bit that sets the game state:

So far, I have over 500 Gary Kasparov games to study.  Time to get busy!