# Aku Kotkavuo

## @eagleflo

I am a software generalist from Helsinki, Finland. I’ve been working with software for most of my life. I practise writing about related topics here.

My open source projects include mpyq and jisho.

# gorb 0.1

13 September 2010

I just laid the finishing touches to gorb version 0.1. In the last post I promised support for keeping track of captured stones and scoring in the next update. I added these features and while doing them I also added support for reading simple board diagrams.

First I tackled informal diagrams that are ideal for quickly setting up some tsumego problems. You can feed the Board object a diagram like this and it will set the board up. Here is an example of such a diagram, in a custom format.

``````> require 'gorb'
> diagram = <<-END
---------------------
| . . . . X O . . . |
| . . . . X O . . . |
| . . . . X O . . . |
| . . . . X O . . . |
| . . . . X O . . . |
| . . . . X O . . . |
| . . . . X O . . . |
| . . . . X O . . . |
| . . . . X O . . . |
---------------------
END
> board = Board.new
``````

`Board#read` works by stripping off everything but dots, Xs and Os. It then assumes that the diagram starts from the upper left corner and starts putting stones in their correct places, switching rows when it encounters a newline. In this way you can actually feed it only partial diagrams, again excellent for tsumego which often require less than the full board. As you can imagine, graphs like this also come in handy when you need to set up board state for tests!

I also wanted to support output produced by gnugo. I haven't actually researched if the output it produces is in any way canonical, but I'd imagine it's a pretty good representative of a slightly more complex diagram. Here is an example.

``````White (O) has captured 5 pieces
Black (X) has captured 3 pieces

A B C D E F G H J K L M N O P Q R S T
19 . . . . . . X O O O O O . O X . . . . 19
18 . . . . X X X X O X X O . O X X . . . 18
17 . . . . X X X O O X X O . . O X X X X 17
16 . X X X O X O O X X X X O O O X O X O 16
15 X X O O O X O O O X O O . . . O O(O)O 15
14 O O . O . O X O X X O . . . . . O O O 14
13 O O O O . O X X . X X O . O . O . . O 13
12 X O X O . O X . . X O . O X O O . O X 12
11 X X X O O X O X . X O . O X X X O O X 11
10 X O X X X X O X . X O O X . . X X X X 10
9 . . . . . X O O X X O X X . . . . . .  9
8 . . . . X X X O O X X . . . . . . . .  8
7 . . . X O O O . O O X X . . . . X . .  7
6 . . . X O . . . . . O O X X X . . . .  6
5 . . . X O . . . . . . . O O O X X . X  5
4 . . . X X O . . . O . . O . O O X X O  4
3 . . . . X O . . . . . . . . . . O O O  3
2 . . X . X O . . . . . . . . . . . . .  2
1 . . . X O O . . . . . . . . . . . . .  1
A B C D E F G H J K L M N O P Q R S T
``````

This format required some magical regexp powers to tame.

I bumped the version up to 0.1 and pushed the latest version into RubyGems. I think I should add support for reading and writing SGF files next.