Any Go "position" is a collection of black
o and empty
. on the board. So I using an 2D array.
o.x.xxx..x xoo.xoxxoo ....x...ox .ox.o.o.o. xox..xx... .xox.x.xx. o..oxxoooo ..o..xxo.o .o...oxoo. .xo..oxxox
I need to identify the components of the same type (
.) connected by horizontal or vertical moves. Diagonal does not count.
...o... vs .x.x oo...oo x.x.
Once I have identified a group, I need to count the liberties or empty spaces around that group.
Here is a group of
x pieces with 9 spaces around it
234 ..ox 1xxx5 .xxxo 89x6 o.xo 7 .
However, 4 of them are covered with
o pieces, and 5 of them have empty spaces
. around it. So our gropu of
x pieces only has 5 liberties.
. should count as 1 liberty, the
o pieces should not count (contribute 0) and the
x pieces should have been included in the group to begin with.
Is there a systematic way to identify connected groups on the board? And then to count the liberties.