In the game of Go, there is the ko rule, which basically states that immediately recapturing a single stone is not a valid move.
I am working on a Go computer program and am trying to implement the ko rule. For efficiency, I am satisfied with a more relaxed definition that aims at two goals:
- It always prevents moves that would illegally recapture a ko
- It never prevents moves that are legal
Currently, I go with:
If in the previous half-turn exactly one single stone was captured, then it is not allowed to play at the position of this stone in the immediately following half-turn (by the other player).
This is relaxed because it does not attempt to detect that a ko is actually present, it is only concerned with preventing an illegal move. For instance:
$$B $$ ------- $$ | . . . . $$ | X X O O $$ | X O 1 O $$ | X X . .
This situation is not a ko, because there is no way to recapture. However, playing at the location of the captured stone is still an invalid move, because it would be suicide. I believe that one or the other (illegal recapture or suicide) always applies.
My question is if my heuristic fulfills the two stated goals. (I think it does.)