Connect your edges
Red links the top and bottom edges; Blue links the left and right. A chain of touching tiles is all it takes.
COMP30024 · Artificial Intelligence · University of Melbourne
In 2022 we built a game-playing agent for Cachex, a Hex-like race to connect opposite edges of a hexagonal board, with captures and a first-move steal. Here it is again, ported line by line from Python to run in your browser.
New here? Take the guided tour · three short walkthroughsThe game
Two players take turns placing a tile on any empty hex. Whoever links their two edges first wins.
Red links the top and bottom edges; Blue links the left and right. A chain of touching tiles is all it takes.
Place a tile that closes a diamond around exactly two enemy tiles, with your own tile opposite, and both enemy tiles are removed.
Red moves first, so Blue may answer by stealing: Red's tile is mirrored across the long diagonal and becomes Blue's.
The coursework
The project came in two parts. We have paraphrased the brief here; the original specification is not reproduced.
The task: given a board with some occupied cells, find a shortest chain of empty cells from a start to a goal using A* with an admissible heuristic, and print its length and cells.
What we built: a CachexBoard of HexNodes with a priority-queue A* over the six hex neighbours, Minkowski heuristics (Manhattan or Euclidean), and an optional colour that blocks the search. A notebook experiment compared the heuristics on hundreds of random boards.
The task: write a player the subject's referee could run against random, greedy and search-based opponents, within time and memory limits.
Six hand-tuned features from weights.json, scored from Red's point of view (Red's count adds, Blue's subtracts).
Number of empty cells left on the board (shared, not per colour).
Tokens that form a solid triangle with two adjacent friendly neighbours.
Tokens of each colour currently on the board.
Sum of cell scores: the rim scores higher than the centre.
Tokens sitting in a half-built diamond the opponent could complete.
Tokens with an exposed gap that invites an attack.
Key results
The agent and search results come from running the original Python, unchanged, with the subject's referee. The port is then checked against those same runs.
wins against the random agent (144 of 160 games, both colours, boards 4 × 4 to 7 × 7; Wilson 95% CI 84.4% to 93.8%)
cells in the A* paths for the two sample inputs, matching the recorded outputs
parity: the TypeScript port reproduces the original paths, node counts, evaluations and moves
20 seeded games per row, generated by scripts/benchmark_agent.py. Wilson 95% intervals; with 20 games a row each one is wide, so the pooled rate is the better summary.
| Board | AgentAgent plays | Win rate (95% CI) | W–L | TurnsAvg turns |
|---|---|---|---|---|
| 4 × 4 | red | 85%[64, 95] | 17–3 | 14.2 |
| 4 × 4 | blue | 75%[53, 89] | 15–5 | 13.8 |
| 5 × 5 | red | 90%[70, 97] | 18–2 | 20.5 |
| 5 × 5 | blue | 95%[76, 99] | 19–1 | 20.1 |
| 6 × 6 | red | 90%[70, 97] | 18–2 | 29.6 |
| 6 × 6 | blue | 90%[70, 97] | 18–2 | 32.2 |
| 7 × 7 | red | 100%[84, 100] | 20–0 | 44.3 |
| 7 × 7 | blue | 95%[76, 99] | 19–1 | 43.5 |
Measured, not claimed
The revival adds a seeded tournament harness, a paired A* study and an optional LLM evaluation, each reported with sample sizes and confidence intervals, plus the decisions and weaknesses behind them.
Round robin against controlled variants, colour-swapped and seeded, with Bradley-Terry strengths and the alpha-beta study.
OpenManhattan vs Euclidean on 980 paired boards: expansions, Wilcoxon test, and how often each finds a shortest path.
OpenBring your own key: a language model plays the agent, with legal-move validation, intervals and an audit log.
OpenProvenance, evaluation design, limitations, decision records, the agent card and the AI use statement.
OpenAbout this project
COMP30024 Artificial Intelligence, University of Melbourne, Semester 1, 2022. Team _4399.
Team _4399, a two-person project. Both members are credited as authors in the original source.
Parity fixtures are produced by running the original code with uv.
The original submission is preserved unchanged in the repository's coursework/ folder for reference. If you are taking COMP30024, please respect academic integrity and do not copy it.