← Back to Portfolio
Artificial Intelligence · CSCI 3202
Mancala AI Agent
A Mancala-playing AI built from scratch in Python (game engine, random
baseline, and search agents), benchmarked head-to-head over 100-game
tournaments. Minimax with alpha-beta pruning plus a custom heuristic lifts win
rate to 99% at depth 5.
Python
NumPy
Matplotlib
99%
win rate at depth 5 with the new heuristic
~3.9×
speedup from alpha-beta pruning at identical win rates
10
deepest search depth made feasible by pruning
100
games per tournament for benchmarking each agent
How it's built
The project is structured as four layers, each independently testable:
- Game engine. A Mancala board with move legality, stone capture, end-of-game detection, and turn alternation, built from scratch so every search agent talks to the same rules.
- Random baseline. Picks any legal move uniformly: the floor every smarter agent has to beat by a wide margin to count.
- Minimax + alpha-beta search. Identical move choices to plain minimax with a fraction of the node visits, making deeper plies practical.
- Custom heuristic evaluation. A linear combination of side-store difference and end-of-game stone-sweep credit, tuned through tournament play.
The interesting part: pruning vs. heuristic
Plain minimax at depth 10 was projected to take roughly two hours per
game, clearly not playable. Alpha-beta pruning kept the same
move choices but cut node visits by enough to make depth-10 search feasible
in seconds, a ~3.9× speedup.
Even with deeper search, win rate against the baseline plateaued around 96%.
The last gains didn't come from more depth. They came from teaching the
heuristic to value end-of-game stone sweeps, which are decisive late in a
game but invisible to a naive score-difference function. That single change
pushed win rate to 99% at depth 5.
Key insight
Past a certain depth, marginal wins come from heuristic design, not raw search.
Crediting end-of-game sweeps was a tiny code change that delivered the
final 3%, bigger than any extra ply of search had.
What I took away
- Alpha-beta isn't just a speedup. It's what makes deeper, otherwise-impractical search affordable in the first place.
- Heuristic design eventually dominates search depth. A small domain-aware tweak beat several plies of additional lookahead.
- Tournament play is the honest benchmark. Single games hide variance; 100-game tournaments make small heuristic edges visible.