Add Gomoku (five-in-a-row) game#15
Merged
Merged
Conversation
New placement game implementing the Game interface: actions index cells (no gravity), with configurable board size and win length (default 9x9 connect-5). Registered with a single line in the games registry, which the recent centralization enables. Tests cover all four win directions, the connect-5 non-win at four marks, a tiny-board draw, canonical perspective encoding, config validation, and registry wiring. alphago-to6
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 Gomoku as a new game in the game-agnostic pipeline. It's a placement game (no gravity): actions index board cells directly, with configurable board size and win length (default 9x9, connect 5). Registered with a single line in the central registry from #13.
Motivation
Exercises the
Gameinterface on a different shape of game than tic-tac-toe / Connect Four — variable, larger action space (cells, not columns) — confirming the network, MCTS, and self-play stay genuinely game-agnostic. Also the first game added since the registry centralization, validating that "add a game" is now a one-line registry entry.Implementation
alphazero/games/gomoku.py:Gomoku(size=9, connect=5)+GomokuState, mirroring ConnectFour's line-scan win check minus gravity.alphazero/games/__init__.py.Testing
tests/test_gomoku.py(18 cases): all four win directions, connect-5 non-win at four marks, tiny-board (3x3) draw, canonical perspective encoding, constructor validation, registry wiring.game_from_name("gomoku")→AlphaZeroNet→ MCTS produces a valid 81-action policy.Review focus
winner()does a full-board scan each call (matches ConnectFour); fine at 9x9, could be optimized to scan only lines through the last move later.Closes
alphago-to6.