A hope also is that this document can serve as a reference for anyone to implement any subset of such rules themselves - including a rigorous nearly-Japanese rules that bots can use for self-play or for competitive matches completely without need for outside adjudication or dispute resolution or any other protocol besides just the bots making ordinary plays.
I believe the nearly-Japanese rules should correctly handle a wide variety of details, so long as both players play to rationally maximize their score. For example:
Starting with an empty grid, the players alternate turns, starting with Black. A turn in the main phase is either a pass or a legal move.
Cleanup Phases
These phases only occur if scoringRule is Territory.
Cleanup is designed to try to match most of the ways that positions would be ruled and scored under normal Japanese rules, so long as players self-interestedly maximize their score during cleanup. Broadly, this is done by giving players 1 point of compensation per move during the (second) cleanup phase, such that the players can now capture dead stones and resolve all disputes without loss of points for filling in territory.
A variety of details are also managed to implement other quirks of Japanese rules. Including there-are-no-points-in-seki, and the Japanese conception of each position as "independent", such that ko threats in one part of the board do not affect the status of the rest of the board. For example, a bent-four-in-the-corner will still resolve as dead under optimal play with these rules even if there are unremovable ko threats on the rest of the board. A lot of the mechanism to do this is based on the Japanese rules themselves, attempting to formalize their spirit to try to make them rigorous enough for self-play.
We do not aim for a 100% perfect match, however. For example, under this ruleset, three-points-without-capturing will (usually) entirely naturally be three points without capturing with no need for any special ruling, matching the traditional Japanese ruling (and in effect, justifying it). But the modern Japanese rules instead regard it as a seki, in which black must concede down to two points to get anything. More exotic kinds of positions will also differ between these rules and Japanese rules.
Cleanup Phase Basics and Definitions
- A ko-move for a player in a position is any pseudolegal move M where the opponent would have a pseudolegal move in response, the ko-reply, that would result in exactly the grid coloring prior to M.
- In addition to the grid coloring, points on the grid may be marked as ko-recapture-blocked.
- The state during cleanup phases consists of the grid coloring together with the ko-recapture-blocked status of all points and the color of the player next to take a turn.
Cleanup Phase Play
Cleanup lasts for two phases[6]. In each phase, starting with the grid coloring from the end of the previous phase, the players alternate turns, starting with the opponent of the player who took the last turn of the previous phase. A turn in the cleanup is either a pass, a legal move, or an unblock-ko-recapture action.[7]
- A pass cedes the turn with no effect (but may possibly end the phase, as described below).
- A legal move by a player during a cleanup phase is any pseudolegal move that either...
- Is NOT a ko-move.
- Is a ko-move that both...
- Does NOT capture any region containing a point marked as ko-recapture-blocked.
- AND where that player did NOT on any earlier turn during the same cleanup phase make a legal move on exactly the same point with exactly the same grid coloring.[8]
Then, followed by marking the point colored by the move as ko-recapture-blocked.
Then, followed by unmarking all ko-recapture-blocked points whose grid color is empty.
- An unblock-ko-recapture action consists of a player choosing a a single-point region of the opposing color that is in atari and marked as ko-recapture-blocked, and removing that mark.
Cleanup Phase Ending and Scoring
A cleanup phase ends after any of:
- There are two consecutive passes.
- OR a player passes from a state that the player has already passed from once before during the same phase.[9]
- OR at the start of a player's turn, the current state has already occurred twice before since the most recent pass by either player during this phase. In this case the not only the phase ends but the entire game immediately ends as well, with a result of "no result".
After the first cleanup phase ends, the second cleanup phase begins immediately with the same grid coloring but with all ko-recapture-blocks unmarked.
After the second cleanup phase ends, the game ends and is scored as follows:
- (if SelfPlayOpts is Enabled): Before scoring, for each color, empty all points of that color within pass-alive-territory of the opposing color. Points emptied this way also add to the total number of captures of that point's color.
- (if TaxRule is None): A player's score is the sum of:
- +1 for every point in empty regions bordered by their color and not by the opposing color.
- + The total number of captures of the opposing color.
- +1 for every move made by that player during the second cleanup phase.
- -1 for every point of their color not within independent-life-regions and that was not their color at the start of the second cleanup phase.
- If the player is white, Komi.
- (if Button is Used): +0.5 if this player was the first to pass during the main phase.
- (if TaxRule is Seki): A player's score is the sum of:
- +1 for every empty point within independent-life-regions of their color.
- + The total number of captures of the opposing color.
- +1 for every move made by that player during the second cleanup phase.
- -1 for every point of their color not within independent-life-regions and that was not their color at the start of the second cleanup phase.
- If the player is white, Komi.
- (if Button is Used): +0.5 if this player was the first to pass during the main phase.
- (if TaxRule is All): A player's score is the sum of:
- +1 for every empty point within independent-life-regions of their color.
- + The total number of captures of the opposing color.
- +1 for every move made by that player during the second cleanup phase.
- -1 for every point of their color not within independent-life-regions and that was not their color at the start of the second cleanup phase.
- -2 points for every independent-life-region of their color.
- If the player is white, Komi.
- (if Button is Used): +0.5 if this player was the first to pass during the main phase.
See
[10] for some remarks about the scoring.
Although handicap games are not a focus of these rules, see [11] for some notes about handicap game scoring.
The player with the higher score wins, or the game is a draw if equal score.
For computer AI training, the following equivalent formulation for a player's score could also be used if desired.
This formulation is much more similar to area scoring, in that it factors over the board as simply a sum of +1/0/-1 for each point on the board, and moves within independent-life-regions by either player do not affect this "ownership" sum whatsoever (so long as dead stones are cleaned up and borders and dame are finished).
- (if TaxRule is None): A player's score is the sum of:
- -1 for every move made by that player in the main phase OR first cleanup phase.
- +1 for every point in empty regions bordered by their color and not by the opposing color.
- +1 for every point of their color that is within independent-life-regions OR that was their color at the start of the second cleanup phase.
- If the player is white, Komi.
- (if Button is Used): +0.5 if this player was the first to pass during the main phase.
- (if TaxRule is Seki): A player's score is the sum of:
- -1 for every move made by that player in the main phase OR first cleanup phase.
- +1 for every empty point within independent-life-regions of their color.
- +1 for every point of their color that is within independent-life-regions OR that was their color at the start of the second cleanup phase.
- If the player is white, Komi.
- (if Button is Used): +0.5 if this player was the first to pass during the main phase.
- (if TaxRule is All): A player's score is the sum of:
- -1 for every move made by that player in the main phase OR first cleanup phase.
- +1 for every empty point within independent-life-regions of their color.
- +1 for every point of their color that is within independent-life-regions OR that was their color at the start of the second cleanup phase.
- -2 points for every independent-life-region of their color.
- If the player is white, Komi.
- (if Button is Used): +0.5 if this player was the first to pass during the main phase.