Ahmed Doghri Logo Image
Ahmed Doghri

connectpuct

A game project should be playable, not just a notebook. connectpuct ships a browser game and a PUCT agent that beats random and center baselines 10 out of 10.

connectpuct, a Connect Four game with a PUCT search agent

A Board Game That Actually Plays Back

I did not want another game AI repo that only prints a score. connectpuct has the engine, the search agent, the benchmark, and a browser page you can open and play.

The game is Connect Four because the tactics are simple enough to inspect and deep enough to punish lazy agents. Immediate wins matter. Blocks matter. Center control matters. Search has to make those tradeoffs in real time.

Search With Useful Priors

The Python agent uses PUCT-style Monte Carlo tree search. Priors favor center columns, immediate wins, and tactical blocks, then rollouts settle the rest.

The web game is dependency-free. The benchmark pits the search agent against random and center-first baselines so the result is not just a screenshot with a board in it.

The Number

connectpuct wins 10 of 10 games against random and 10 of 10 against the center baseline in the checked benchmark.

4 tests pass locally and on GitHub Actions across Python 3.9, 3.11, and 3.13. The playable game lives at `web/index.html`.

Tools Used

Python
JavaScript
MCTS
PUCT
Game AI
pytest
GitHub Actions CI