Greg Klein's Blog

Archive for the ‘chess’ Category

Chess (and why data is fun)

leave a comment »

I’ve been playing chess (and with chess) quite a lot recently. I started up playing online chess again (on chess.com), and I’ve been having quite a lot of fun with it. This quickly moved into playing with chess in Python, and I’ve had quite a lot of fun with that, especially thanks to a nifty chess library I found for python. One of the things I realized is that chess.com makes quite a lot of data available for each user. For example, I can download a .pgn file of the last few weeks of games that I have played (I ended up downloading about 40 chess games that I’ve played — I could get more games but unfortunately I need to pay for a real account if I want this).

This is a lot of data, so I decided to try to do something with it. I ended up producing this:

All of the chess moves that I've made in the last 4 weeks.

All of the chess moves that I’ve made in the last 4 weeks.

This represents all of the chess moves made in about 40 chess games I’ve played, coloured by piece. Rooks are gold, kings are purple, pawns are blue, bishops are green, knights are red, and queens are black. I also made a few images representing only certain pieces, here’s one with only the knights:

All of the moves made by knights in my recent games.

All of the moves made by knights in my recent games.

Most of the work that I did on this project actually went into producing the graphics rather than interpreting the files. I got the best results (that you see here) by using PYX curves. Each arc that you see in the images represents a move. The degree of the arcs (how wide the are, etc) is randomly generated so that multiple “moves” don’t overlap. This way we can see, that, for example, I like to move my knights to c3 and g3 quite a lot.

Oh, and if you’d like to play chess with me, feel free to challenge me online. I can’t guarantee that I’m any good at chess, though, so it might be a bit embarrassing for me.

Written by gregklein

January 22, 2013 at 4:50 pm

Posted in chess, python