Add Go (7x7) with ko, suicide rule, and area scoring#16
Merged
Conversation
New game module implementing the Game interface for Go: a pass action (action_size = size^2 + 1), flood-fill captures, a no-suicide legality rule, simple single-point ko, two-pass termination, and Tromp-Taylor area scoring with a half-integer komi (so results are always decisive). Board size and komi are configurable (default 7x7, komi 7.5). Registered via the central registry. Simple single-point ko is used instead of full positional superko to keep GoState small and hashable for MCTS; documented in the module. Tests cover captures, plain suicide vs capturing-suicide, the ko ban and its clearing, two-pass termination, and area scoring with komi and territory attribution. alphago-xdh
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds Go — the project's namesake and most involved game — to the game-agnostic pipeline. 7x7 by default, with a pass action, captures, suicide prohibition, ko, two-pass termination, and Tromp-Taylor area scoring.
Motivation
Go stresses the
Gameinterface in ways no prior game did: a non-spatial pass action (action_size = size² + 1) and history-dependent legality (ko). Implementing it on the same interface — with no changes to MCTS, the network, or training — is the strongest evidence the pipeline is genuinely game-agnostic.Rule choices (documented in the module)
GoStatesmall and hashable and covers the common case.Testing
tests/test_go.py(12 cases): captures, plain suicide (illegal) vs capturing-suicide (legal), the ko ban + its clearing on a pass, two-pass termination, empty-board komi result, and territory attribution in area scoring.game_from_name("go")→AlphaZeroNet→ MCTS yields a valid 50-action policy (including pass).Review focus
legal_movesdoes a place+flood-fill suicide check per empty point (O(points²)); fine at 7x7, a known hot spot if scaled up.Closes
alphago-xdh.