This may be an instance where bitmaps would be handy - altho expensive in terms
of memory - a bitmap would require NxN bits for each string of connected stones.
For each connected string, maintain a bitmap of adjacent liberties. When two
strings are connected, add the two bitmaps together - this
Pseudoliberties, as someone here explained recently, are a count of how
many adjacent empty spaces a program would find around a chain of stones
if it didn't bother to correct for how many times the same space gets
counted from different directions.
example
0 0 . .
X X 0 .
. X 0 .
. 0 . . The X's