Skip to content

Add Gomoku (five-in-a-row) game#15

Merged
cweill merged 1 commit into
mainfrom
feature/gomoku
May 26, 2026
Merged

Add Gomoku (five-in-a-row) game#15
cweill merged 1 commit into
mainfrom
feature/gomoku

Conversation

@cweill

@cweill cweill commented May 26, 2026

Copy link
Copy Markdown
Contributor

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 Game interface 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.
  • One-line registry entry in alphazero/games/__init__.py.

Testing

  • Full suite: 129 passed.
  • New 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.
  • Pipeline integration smoke: game_from_name("gomoku")AlphaZeroNet → MCTS produces a valid 81-action policy.

Review focus

  • Default board 9x9 / connect 5 — reasonable, or prefer a smaller default for faster self-play?
  • 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.

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
@cweill cweill merged commit 52a2286 into main May 26, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant