A famous recently-solved problem in AI, Go is a board game played by two players on a square board. Both players can only place stones (either white or black) on open spaces of the board. Stones that are adjacent to each other form a group.
For example, consider the following 3x3 board:
w w -
b - -
- b b
There are 3 groups of stones on this board, one white and two black. The most important property of a group of stones is the number of empty spaces on the outside of it. These empty spaces are known as the group’s liberties.
In the example above:
The group at position 2,2 (the bottom right corner) has 3 liberties.
The group at position 1,0 (the left edge) has 2 liberties.
The group at position 0,1 (the top) has 2 liberties.
Given as input a Go board and the location of one stone on the board, can you count the number of liberties of this group?