Why programmers should play Go

Posted by Jon
on Monday, July 14

Go is an ancient strategy game with simple rules and a profound degree of complexity.

Software development is the art of managing complexity using a limited number of rules, structures, and patterns.

Programmers should play Go.

Go in 28 words or less.

The beauty of Go is its combination of simplicity and complexity. On the one hand, go has only a handful of rules. Place stones, don’t get completely surrounded, control territory. Like chess, the mechanics can be picked up in a few minutes, though Go only has a single type of “move”, and only one edge case (the ko rule). And like chess, one can spend a lifetime discovering the strategic and tactical layers of the game.

While chess is quite complex and rich, such that it took a 30-node supercomputer to defeat the reining chess champion, no computer comes close to defeating even a skilled amateur Go player. There are 361 positions on a Go board, and with two players, there are 2.08168199382×10170 valid positions. That’s quite a bit bigger than a googol (yes, that is the correct spelling). Realistically, there are something on the order of 10400 possible ways that a typical game could play out. And the number of possible moves roughly follows 361!, which means that only 20 moves in, there are many googols of possible ways that the game could shake down. (As a fun exercise, try plugging 361! into an online factorial calculator.)

Managing complexity

So how does one play Go, given this near-infinite complexity? On a tactical level, a player approaches Go like chess, thinking several moves ahead. But this only works in small spaces, like a tight battle in a small sector of the board. Beyond there, there are just too many possibilities. So on a strategic level, a player must think in shapes or patterns. These shapes provide shorthand ways of managing the complexity of Go. As a non-master, I may have no idea how things will proceed in one sector of the board, but I may be able to recognize strong and weak patterns of stones, vulnerable shapes and effective formations.

But there’s more: Go has several sorts of patterns. Beyond shapes, there are Go proverbs. These can be general: “Your opponent’s good move is your good move”; specific: “Don’t try to cut the one-point jump”; funny: “Even a moron connects against a peep”; and meta: “Don’t follow proverbs blindly.” These proverbs are principles which help a player make good decisions. They are less specific than shapes, and so they provide guidelines for whatever situations may arise on the Go board. Proverbs often conflict, and a player must determine when and how to apply them.

Finally, there are joseki. Joseki are patterns of play that are considered even for both sides. They typically happen in the corners of the board, and typically at the beginning of the game. Interestingly, there is a Go proverb that says “Learning joeski costs two stones,” meaning that memorizing these patterns isn’t helpful. Instead, a player should learn from joseki by understanding what is going on in each move.

Patterns in Go, patterns in software design

Each of these Go patterns has a rough programming analogue.

Shapes in Go aren’t unlike software design patterns. While there is nothing preventing you from placing logic in your views, this shape is recognized to be a weak one. Think of Gang-of-Four design patterns: the MVC, Adapter, and Factory patterns are recognized to be helpful in some circumstances (and not appropriate in others). On a lower level, iteration and recursion have commonly recognized shapes, as do database normalization vs. denormalization. Even if you can’t hold an entire program or algorithm in your head at once, recognizing common shapes helps you to understand what is going on.

Go proverbs are like another type of pattern in software: CapitalizedPrinciples (for lack of a better term) made popular by Extreme Programming. Think DontRepeatYourself, YouArentGonnaNeedIt, CollectiveCodeOwnership, DailyBuild, TestFirst. These aren’t specific code “shapes”, like a singleton class – they are general principles that guide the practice of programming.

Because joseki is about exchange between competing parties, its programming parallel is a little less clear. The closest comparison, in my mind, is programming exercises. This article, for instance, suggests 9 exercises to help you become a better OO programmer, like:

  • Use only one dot per line
  • Use only one level of indentation per method
  • Don’t use setters, getters, or properties

In a real-world program, you’re unlikely to stick to these principles 100% of the time. But forcing yourself to write code in this way can be an eye-opening experience and can make you a better developer.

So what can Go really do for you?

Obviously, these parallels are structural. Specific Go proverbs (“Your opponent’s good move is your good move”) may not have direct relevance to software development. So can Go really make you a better developer?

I think it can, and I’ll go one further. I think Go can make you smarter. There is a lot of anecdotal evidence to this effect [1] [2] [3], for example [4]:

In fact, all of our minds can benefit from playing Go, which officially has the capacity to make you smarter. Research has shown that that children who play Go have the potential for greater intelligence, since it motivates both the right and left sides of the brain.

The research mentioned isn’t footnoted, unfortunately, so take statements like this with a grain of salt.

But it makes sense: like chess, Go requires pattern recognition, a mix of strategic and tactical thinking, and comprehension of complex structures, though in Go the patterns are larger and the complexity is greater. A mind trained to think in these ways is going to have an easier time attacking similar problems in other spheres.

Like software development.

Image by andres_colmen: http://flickr.com/photos/andres-colmen/2539473895/


Leave a response

  1. AkitaOnRailsJuly 14, 2008 @ 01:05 PM

    Amazing article! I’ve always thought of Go and programming together as well. As a japanese I “know” about Go for a long time, but I never actually learned through. I know the basics but not much more than that.

    If one need a more “visual” inspiration – and like animation – you could try Hikaru no Go

    I think Go is one of the most ancient board game still played in its original form. Deceptively easy to do the first step, incredibly difficult to play the second. You can also try Net Go through online server’s such as IGS

  2. kenJuly 14, 2008 @ 03:01 PM

    To be fair, the simplest variant of the ko rule (“can’t repeat a board position”) seems like less of an edge case to me than other common rules, like the suicide rule.

  3. Jon DahlJuly 14, 2008 @ 03:23 PM

    Akita, I wasn’t familiar with Hikaru no Go – interesting that manga could significantly increase the popularity of Go in Japan.

    Ken: when I first started playing, ko seemed like an exception, or an extra rule. But I think you’re right – thinking about it philosophically (“can’t repeat a board position” or “the game must always move forward”) is a better way of looking at it.

  4. aApeJuly 14, 2008 @ 03:27 PM

    judging by most of the programmers i know, they should really play some basketball or go skating or something, rather than play go.

  5. JoeJuly 14, 2008 @ 03:39 PM

    “officially has the capacity to make you smarter”

    By these measures, everything has the capacity to make you smarter.

  6. Luke FranclJuly 14, 2008 @ 04:00 PM

    aApe—that’s a future post. ;)

  7. RyanJuly 14, 2008 @ 04:05 PM

    Go is awesome, I enthusiastically agree with this entire article.

    Unfortunately, no one within 100km of where I live has even heard of it :/ Playing with a real person can’t compare with getting destroyed by some guru online.

    @Joe: “By these measures, everything has the capacity to make you smarter.”

    And, generally speaking, he’s right. Obviously we can exclude things like sniffing glue or riding shopping carts down hills, but just about everything sensible can make you smarter – or at the very least provide you with more experience, and that’s never a bad thing.

  8. someguyJuly 14, 2008 @ 04:31 PM

    One of the first lessons from the Computer science department of my university was to play Go!

  9. Liam MorleyJuly 14, 2008 @ 04:38 PM

    Very rarely do I read blog articles with a large smile on my face. This is one of those times. As a Go novice (how many years will I have to play Go before I can shake that title?) and programmer, I agree with everything you’ve written above.

  10. Alf MikulaJuly 14, 2008 @ 04:52 PM

    If any of you Ruby / Rails developers are interested, I’m working on a new web site to promote Go in the United States (and elsewhere, eventually) by creating a place where Go players can arrange games to play in person. The current promotego.org site is broken, but I’m working on a rewrite in Rails. Email me at contact@promotego.org if you’re interested.


  11. MitchJuly 14, 2008 @ 04:59 PM

    Absolutely agree with you. Go is quite easy to learn but difficult to master. One must avoid the tendency to play your stones to close!

  12. MichelJuly 14, 2008 @ 05:08 PM

    At least two other developers and I won’t be able to attend the Rails Summit Brazil 2008 because we will be playing Go at the World Mind Sports Games in Beijing (http://www.2008wmsg.org/). Talk about coincidences :-)

  13. Steven G. HarmsJuly 14, 2008 @ 05:52 PM

    I got quite into Go a while back and will certainly again be doing so because my girlfriend bought be a new beautiful bamboo board!

    A good way to learn is to play on-line at Yahoo! games–beware though, people from Asia know those maxims like the back of their hands and one must not let one’s pride get too eroded by having a 12 year-old in Guangdong beat you like a step-child.


    Editor: While you did spell “gogol” correctly, it’s “reigning”, not “reining”, btw.

  14. Raymond CayananJuly 14, 2008 @ 09:18 PM

    A very good article I must say, I remember seeing this game from the movie “A Beautiful Mind”, remember when John Nash(played by Russell Crowe) was playing with his college buddy. Anyway I hope its not too late for me to be playing this one.

  15. IzkataJuly 14, 2008 @ 09:36 PM

    Jon, Akita, when Hikaru no Go was first officially translated to English, it caused a rise in Go popularity among teenagers in the US, as well. It’s actually the whole reason I know how to play, although I haven’t for a couple years now.

    Here’s an interesting note on your comment on proverbs: There are multi-level proverbs, too, and you used one. “Learning joseki costs two stones.” (Also, you misspelled it in that quote) Your interpretation is that learning joseki by rote costs you two stones score-wise.

    However, what I noticed to be a much more valid interpretation when I played online on the KGS servers was this: Learning joseki, and why they’re good, costs you two handicap stones. In other words, learning the reasoning behind joseki greatly increases your skill level.

  16. RistoJuly 14, 2008 @ 10:05 PM

    Izkata, you said exactly what I was. I originally picked up Go from reading Hikaru, and spent some time playing on KGS (invaluable to people like Ryan that are not near any other players) and actually learned what I was doing by reading Janice Kim’s “Learn to play Go” series.

    I actually brought in a set of stones and a homemade cloth goban into the office, but I have yet to sucker any of my colleagues into a game.

    And remember, “Proverbs do not apply to White.”

  17. WillJuly 14, 2008 @ 10:13 PM

    Joseki are to Go as Design Patterns are to software.

  18. TaishiJuly 14, 2008 @ 10:19 PM

    I would not recommend playing Go on Yahoo. It’s controls allows for some abuse.

    KGS is much better and will allow you to play over the web with their Java client.  IGS is another good one but can be a little more intimidating to new players.
  19. pareshJuly 14, 2008 @ 10:22 PM

    nice article.

  20. EricJuly 14, 2008 @ 11:03 PM

    i just started playing go about 2 months ago (just finished building my own board) and i think this article hits the nail on the head. it’s an amazing game.

  21. AkitaOnRailsJuly 14, 2008 @ 11:09 PM

    Just translated this article into portuguese and added a few notes at the end ;-)

  22. Trevor TurkJuly 14, 2008 @ 11:50 PM

    Fantastic – now I have another reason to prefer Go to Chess :)

  23. James MunroeJuly 15, 2008 @ 12:30 AM

    Go fans who like spy novels and have an interest in Japanese culture should read Shibumi by Trevanian. It features a Japanese Go master whose signature quote is, “Life is a simplified version of Go.”

  24. Internet TVJuly 15, 2008 @ 01:12 AM

    Will have to check it out, haven’t heard of Go before. Looks a lot like pente.

  25. Peter WendesJuly 15, 2008 @ 05:23 AM

    Nice article, which seems to be making its way around the grapevine. Zen Machine is one of the very few full-time Go promoters in the West, based in the UK, but we came to CA a couple of years ago to run a workshop for the California Association for the Gifted, and will be back in December 08 if any of your readers would like a hands-on introductory seminar.

    Best wishes Peter and Sheila Wendes

  26. MaReK OlsavskyJuly 15, 2008 @ 06:05 AM

    Great blogspot, i’m software developer and occasional Go player. Is possible translate your article into Czech Language?

  27. MalJuly 15, 2008 @ 09:57 AM

    It is also worth mentioning that ‘reading’ in Go is similar to ‘running the code in your head’

  28. Brig LamoreauxJuly 15, 2008 @ 10:07 AM

    I love playing go as much as I love software development. I feel playing go keeps my mind active. It helps me think in abstract and conceptual terms. Each game of Go seems to have a lesson that can be applied to life and in turn to Software. Thanks for the article and great comparison between my two passions.

  29. Nikola StjeljaJuly 15, 2008 @ 02:12 PM

    I completely agree with you. GO is a wonderful game, that both teaches strategy and abstract thought. I think everybody should play it. The remark about young kids being smarter by playing GO, sure got my attention given the fact that I have a seven months old boy in my home. I’ll sure be teaching him this game when grows older.

  30. Jon DahlJuly 15, 2008 @ 02:45 PM

    Thanks to everyone for their comments! It’s great to hear everyone’s personal experiences with the game, and its connection to software. If anyone in the Twin Cities wants to play sometime, let me know. (There’s also a local Go club – http://www.tcgo.org/times.shtml – that I’ve been meaning to check out.)

    Marek and Akita: you’re more than welcome to translate this article – just include a link back here.

  31. grikdogJuly 15, 2008 @ 05:45 PM

    Go is strenuous, especially if you sit in seiza. A game “for real” may take an hour or more against two strong opponents, and at the shodan level (modestly considered the beginner’s level among Japanese pros – the name translates well as “black belt”) the memorization that happens in a normal game is nearly incomprehensible to Westerners. Strong pros can play each other blindfolded, or even weirder, play both sides using one color, usually white. It is not even out of the ordinary for a Go master to play a teaching game with a pupil, put the stones back in their bowls, and then replay the entire game from memory, with running commentary. Your head begins to process the 19×19 board differently, once you’ve begun playing at mid-kyu level – the board acquires depth, and I’m pretty sure one of its dimensions is the fourth. To be sure, programmers understand coding a similar way – seeing not only the form of the symbols but the flow of logic and control – but I would humbly submit, as a retired programmer and an idiot Go beginner, that the scales of comparison are vastly different. Go is absolutely abstract, like mathematics, but programming ultimately refers to the inconvenience, delay and the unexpected, in short, reality. Users understand programs. Only other Go players understand Go players.

  32. AbrahamJuly 17, 2008 @ 12:13 AM

    Regardless of the truth of this article (honestly I could not say either way) it was a good read. I’ve dabbled in both Go and programming, but I’ve never gone far with either. Maybe I’m just not cut for them, or more likely, they require lots of time and patience which I’m not willing to sacrifice. Well, while I’m off “finding the inner me” you keep up the good work!

  33. BG KoJuly 17, 2008 @ 07:05 AM

    thanks a lot for summarizing this. I’ve been saying this my transition from EE to SW Engineer is inspired by playing GO (BaDuk in korean, as matter of fact that japanese players are among weaker player in far east).

    I’d would say it fits like gloves from playing Go to programming

    I played Go(Buduk) for few years before looking at programming and instanly recognized that it ain’t that much different from playing Buduk.

    thanks a again for summarizing this.

  34. Reece HartJuly 18, 2008 @ 04:33 PM

    I have another take on joseki. Joseki, and the game of go, is about balance as much as it is about life and death. I remember being told that the best players try to win by one stone, which seems more like coexistence rather than domination. A related lesson (I’m unsure that it’s a proverb) is that one will lose the game if one cedes all four corners or less obviously, if one captures all four corners. So, perhaps joseki are akin to modular programming with contracts. The best software components are those that do their jobs fully and simply and nothing else, and make that contract (balance) with their callers clear.

  35. JDLJuly 20, 2008 @ 02:52 PM

    Jon, TCGO has some really cool people. I had no problem being an unknown and was welcomed into a series of 9×9 training matches with someone who was much stronger than me. He reviewed our games with me, and then I played against others who were more equal to my own ability. I had a good time, and plan to go back more often once the disc golf season winds down.

    KGS is also a great online site for playing Go. I highly recommend the CGoban 3 client for OS X.


  36. AlotorJuly 24, 2008 @ 10:44 AM

    Excellent article!! I couldn’t agree more. I’ve tried serveral times to play go, but unfortunately it’s harder than it seems. Once you’ve been humiliated at IGS a couple of times you start to lose the initial motivation :P

    Anyway, here a good resource for people interested in sw development + go. GNU has a project for a free implementation of a go program. Check it out at: http://www.gnu.org/software/gnugo/


  37. JeffreyJuly 28, 2008 @ 10:16 PM

    Good article. I was tipped to your site by a blogger friend who saw my post on Cyberwarfare and the game of Go. http://bit.ly/1vRQDN

  38. pwallAugust 07, 2008 @ 11:29 PM

    Here is one of my favorite geeky Go combos.


    This is a Linux distro deticated entirely to learning and playing Go.

    I am trying to get my feet wet in the programing world but am a Go addict so I am glad to know I probably have the right penchant for programing.

  39. uxpAugust 10, 2008 @ 01:23 PM

    Just came to the article via StumbledUpon.

    Go is an amazingly fun game, and more challenging, IMO than chess.

    A little tidbit of knowledge: Googol was the inspiration to two college students to develop the now largest search engine on the internet.