Projects · AI course project

Gomoku Lab

A 15 × 15 Gomoku course project spanning heuristic search, Minimax, MCTS and AlphaZero-style experiments, with a regression-tested VCF solver.

Repository ↗

gomoku-lab is an older course project that became useful again because some search logic that had been treated as finished was not actually correct.

A 2026 maintenance pass reproduced a VCF (Victory by Continuous Fours) bug: the original code could confuse the absence of a real winning completion with a forcing line, mishandle double threats, and ignore optional forbidden-move legality. The corrected search now counts legal immediate winning completions, treats two completions as an unstoppable double threat, recurses only through a unique forced block, prioritizes the side-to-move's immediate win, and regression-tests state restoration.

Seven deterministic VCF tests now cover these semantics.

What the platform contains

The project is organized as a rules engine, a Tkinter interface, and a ladder of engines that all expose the same get_best_move interface:

  • a greedy baseline that wins, blocks, or plays adjacent;
  • iterative-deepening Minimax with alpha-beta pruning, killer and history heuristics, a Zobrist transposition table, and a pattern-based evaluation of fives, open fours, double threats, and open threes;
  • Monte Carlo tree search with UCB1, RAVE, and progressive widening;
  • an AlphaZero-style residual network with PUCT search and a self-play training pipeline, which degrades to random play when PyTorch is not installed.

The rules engine supports standard forbidden-move detection for black (overlines, double threes, double fours), and the interface supports player-versus-player, player-versus-engine, engine-versus-engine, and game-record replay.