I am currently writing some code to deal with Go boards. A Go board is represented as an array of colors. The array has size
× size
entries and represents a two-dimensional square board.
enum color {
EMPTY,
BLACK,
WHITE,
};
struct go_board {
unsigned int size;
enum color intersections[];
};
When enum color player
moves, the following procedure applies: (See rules)
- [...]
- a point P, not colored C, is said to reach C, if there is a path of (vertically or horizontally) adjacent points of P's color from P to a point of color C.
- Clearing a color is the process of emptying all points of that color that don't reach empty.
- [...]
- A move consists of [...] clearing the opponent color, and then clearing one's own color.
I am looking for a fast (in terms of noth computational complexity and actual speed) algorithm to clear a board. Can you help me?