Chess and Territory: My FEN Viewer

One important notion in chess (and in other board games as Go) is the notion of territory. Which squares on the board do you control? How many of your pieces are attacking a certain square, and how many of your opponent are trying to control it too? This is an important concept to have in mind and I never saw this idea implemented in chess software.

Many chess software uses highlighted squares to provide some kind of information like the last move played, possible destination squares for a piece, etc… Also in some cases some chess software provides sound cues to what’s happening, e.g. the clocking running down or announcing checks. Digital chess software is changing the way the game is played, but I haven’t seen any chess software implementing the territory information idea.

fen-viewer Chess Influence Viewer

So, I decided to hack a bit of code and do it myself. Create a territory viewer for chess. It just adds how many pieces are attacking a certain square. Positive for white, negative for black. You can fork the code from github.

The idea is that each square displays the difference between the number of white and black pieces attacking that square. It doesn’t take into account the value of the pieces attacking (that could also be done). But it the most interesting thing is that it provides a visual, on the board, display of territory and influence, something that could be useful in many situations.

Right now this code just parses FEN strings to display the territory controlled by each player. Maybe latter this can evolve into something more elaborate, either as a pgn viewer or chess app that you can use to play against others. Probably the best solution would be to someone to write plugins to already existing good chess database software like chessx or raptor.

update: Comment from Vitorino Ramos

David, the idea is excellent, and really I never saw it implemented anywhere. Maybe you could try the following, in order to have an idea of the relational forces on each square, as you mention, value pieces are important here. Let’s have in mind the e4 square. Two black pieces are controlling it (N=3+B=3 =>6) and just one white piece is defending (p=1 =>1). Now, besides the fact that your colour code shows black is controlling that square, who really wins (at least in material form, not the rest, could be a good sacrifice) if black decides to play either Ne4 or Be4? E.g. Knight (N) plays e4, pawn takes, and Bishop takes e4. That is a -2 loss for black or +2 for white. So maybe you should colour that square +2! Now, let’s see what happens in d4 (black to play): Q takes d4, Q takes d4, Knight takes d4. According to the new code rule, that is now a -1 (in this case, as it was).Remember, that you should start exchanging from minor pieces to more valued ones, whenever possible. For instance in e6 we assume black will take the white pawn with f7 not with the Bishop in f5.Also according to this, c2 and d3 are +3 squares, that is where black should by “any means” avoid. Unless, again as I said earlier, it would be a good sacrifice. This is chess, not checkers :) But that, will be hard to code!

Thank you for these suggestions Vitorino. In reality I’ve just hacked a Java App for with a simple attacking pieces count, but with a bit more work this could be even more powerful. I think this could be a very good teaching tool to show the importance of square control to kids just starting to learn chess.

update Jan 28: There’s a ongoing discussion about this chess software and chess visualisation going on on Reddit