Building an Oware Engine

Oware is a compact two-player strategy game whose rules create non-trivial software problems: cyclic sowing, conditional capture, starvation prevention, endgame handling, and adversarial search. A small board does not imply a small state space or an easy implementation.

Rules as executable invariants

The engine represents the twelve pits, captured-seed scores, and active player as an immutable game state. Move generation must distinguish candidate pits from legally playable moves, particularly when the opponent has no seeds.

Sowing skips the origin pit when a move completes a full circuit. Capture is evaluated backwards on the opponent's side for pits containing the required number of seeds, subject to the rule preventing a move from starving the opponent when an alternative exists.

These rules are tested through examples, boundary cases, conservation of the total seed count, and comparison between independent operations.

Search

A conventional engine can use minimax or negamax search with alpha-beta pruning. Performance improves through move ordering, cached sowing operations, and transposition tables storing bounds for previously evaluated states.

The evaluation function combines score, material distribution, mobility, and tactical exposure. Its weights should be judged through games and controlled positions rather than selected because they sound strategically plausible.

Self-play

Self-play provides data and an evaluation environment, but it can also amplify the engine's own blind spots. Reproducible experiments therefore need fixed seeds, recorded configurations, distinct training and evaluation opponents, and enough games to estimate uncertainty.

Reinforcement learning

A PyTorch model can estimate policy and value from board states. The complete pipeline includes state encoding, exploration, replay storage, optimisation, checkpointing, and an arena that compares a candidate model with a reference.

Promotion should depend on statistically meaningful match results, not a short winning streak. Stronger search around a weak model may improve play while concealing that the learned representation itself has stagnated.

Why this project matters

The project is a useful laboratory for clean domain modelling, algorithmic performance, testing, and machine-learning evaluation. It also demonstrates a general lesson: getting a complex program to run is the beginning of validation, not the end.