For Go I had something like this in mind:
Code: Select all
Kill(x, y, chaintype, delete, d)
{
if(OFFBOARD(x,y)) return 0;
piece = board[x][y];
if(piece == EMPTY) return 1;
n = 0;
if(piece != chaintype && d > 0) return 0;
board[x][y] = TEMP; // mark as visited
do {
n += Kill(x+1, y, chaintype, delete, d+1);
n += Kill(x-1, y, chaintype, delete, d+1);
n += Kill(x, y+1, chaintype, delete, d+1);
n += Kill(x, y-1, chaintype, delete, d+1);
board[x][y] = delete ? EMPTY : piece;
delete = TRUE;
} while(n == 0 && d++ == 1); // redo from d=1 node with delete = TRUE if no eyes
return n;
}
MakeMove(...)
{
....
if(variant == GO)
Kill(toX, toY, OPPONENT, FALSE, 0);
if(variant == CHECKERS)
ClearRay(fromX, fromY, toX, toY);
if(variant == REVERSI)
...
}