Go, the ancient board game

1 September 2010

In year 2002 I encountered Go, the ancient oriental board game, for the first time. Back then I was studying Japanese and reading a lot of manga when I came across one about an old board game. I was pretty intrigued from the outset: how could you possibly tell an interesting story about a board game? I was pleasantly surprised, along with many others: ヒカルの碁 (Hikaru no Go) took the manga-reading world by storm and introduced this ancient game to a lot of people.

After reading about playing go I decided to learn how to play it myself. I found KGS, an online Go server pretty quickly and started playing there regularly. After the initial giant leaps of progress I felt like I hit a wall and stopped playing for almost a year. Ever since I've been playing it in an “on again, off again” manner.

Over the years I thought about making my own virtual Go board for fun and exercise, and sometime in 2008 I finally decided to go ahead and do it. The result was goban, the first project I published on Github. Goban is written in Python and comes with a PyGame -based GUI to provide immediate feedback. I'm still pretty proud of how it came into shape: I started with the GUI and thus could immediately test the real library as it was being written. However, PyGame has been pretty inactive during these years and only recently got support for antialiased circles, which are absolutely essential for drawing the stones. I also omitted tests because I used the GUI to test manually, something that really bit me in the ass later on when I encountered trouble with capturing by filling dame and the ko rule. After I stopped playing go again I promptly forgot about goban for over a year.

Some time last year after getting more familiar with the new possibilities HTML5 offered it dawned on me: how cool would it be to create a HTML5 based virtual go board? That would solve a major problem that plagued my last attempt: nobody wants to install Python and PyGame to try it out. But everyone has a browser, and by hiding the go engine behind the server it would be trivial for anyone to try it. I had heard great things about this new minimal Ruby web framework called Sinatra and together with HTML5, canvas and JavaScript it turned out to be a really nice way to prototype web apps. w2go (way to go), a browser-based go board is my first Sinatra app. Using canvas to draw the board worked beautifully. I was astonished how easy it was to develop a fully working go front end with these technologies. Sadly w2go was lacking the engine itself: pretty GUI will be nothing but a useless toy without some logic behind it. Goban could not be used directly because it was written in Python and Sinatra apps are supposed to be written in Ruby.

Now that I'm about to start playing again I'm ready to unveil something I've been tinkering with in my spare time for a while: gorb. Gorb is in many ways an improved version of goban that has been translated to Ruby. Learning from past mistakes, I started by writing an extensive suite of unit tests to really get the rules down, including all the corner cases. Gorb finally passes this entire test suite and I now feel comfortable enough with it to publish its initial version on Github. It supports the Japanese rules and can handle both handicaps and non-standard komi with ease.

Gorb will be the heart of w2go, and both of these two projects are under heavy further development. Expect to see support for solving sets of tsumego problems, scoring and reading SGF files soon. I've also been planning to create some sort of interactive introduction to go with w2go. In the meanwhile, go ahead and take a look at these projects!