All projects

UMass Amherst · 2026

Misere Nim Agent

An adversarial search agent for misere Nim. Iterative-deepening minimax, alpha-beta pruning, transposition caching, and a domain evaluator, all inside a one second per move limit.

Context
UMass Amherst
Year
2026
Method
Python

Misere Nim inverts the usual rule: you may take any number of sticks from one pile, and whoever takes the last stick loses. That inversion breaks the textbook nim-sum strategy near the end of the game, which is exactly what makes it worth writing a real search for.

The agent runs iterative-deepening minimax with alpha-beta pruning, a transposition table keyed on the sorted pile shape, and move ordering driven by a misere-specific evaluation function. Ordering is where most of the pruning actually comes from. Alpha-beta on unordered moves is close to plain minimax.

The server allows one second per action, so I budget 0.82 and check the deadline inside the search. Before any search begins the agent computes a known-good fallback move, so if the clock runs out it still returns something legal rather than timing out. Designing for the deadline first, then making it smarter inside that budget, is the same discipline as any latency-bound model.

Tools & methods

  • Python
  • Minimax
  • Alpha-beta pruning
  • Memoisation