Wednesday, September 02, 2009

[Hack]: Chess runner

As I wrote a while back, I spend quite some time playing chess on the iPhone using Glaurung app. The interesting feature is that it sends out email of your game describing the game in the Algebraic Notation. I mentioned at the end of the blog that I wanted to have a simulator/runner, that basically runs the entire game when this email is fed to it. I couldn't find one online - so I built one.

The easy part is to take the data, store it, parse it and the simple UI I built for making the moves work. What is infinitely more complex is to understand the moves in the algebraic notation and changing the status of the board. The problem is that the notation only tells you where something is to end up at, not where it originates from - and that has to be computed by you based on your previous board state and a complex set of rules.

The one that I built looks ugly in code presently (and hence not sharing right away), but it works, including moves like castles and en passants. The UI itself is just two pages - one to feed your game and another to run it. If you want to embed the "run" page, you can do that too by adding "&nfh=1" to the end of the page URL.

So check it out at http://www.shreeni.info/chess/index.jsp or check out one of my wins.

Administrative note

All tech posts have now moved to http://tech.shreeni.info or you may subscribe to its RSS feed. In due course, I shall be moving it out completely, so if you follow my tech posts, please shift to following that blog.