2026
Pac-Man AI
Browser-playable Pac-Man with comparative AI agent evaluation
Overview
A browser-first Pac-Man built as a playable game and an AI portfolio piece. I rebuilt the arcade loop on a clean deterministic core, then used it as a controlled sandbox for comparing decision-making strategies in the browser, from random baselines up to pathfinding and behavior trees.
The Problem
Most AI game demos are toy scripts with no architecture, or heavyweight ML setups that are hard to run and harder to compare. This one is a playable game with a structured controller interface, a headless evaluation engine, and a Reports UI for running fair multi-agent comparisons at scale.
My Role
Built the whole system solo: game engine, rendering pipeline, controller abstraction, all five AI agents, the headless evaluator, trajectory logging, and the Reports dashboard.
Key Features
- —Deterministic tile-based Pac-Man engine with ghost personalities, release timers, frightened mode, and full scoring rules
- —Shared controller interface: human and AI agents use the same action API and legal-action system
- —Five AI controllers: Random, Greedy Pellet, Ghost Avoidance, A* (danger-aware path cost), and Behavior Tree
- —Headless evaluation engine that runs thousands of seeded episodes without the Canvas loop
- —Reports tab for multi-agent comparison: average score, win rate, death rate, survival time, pellets, ghosts eaten, decision latency
- —Async episode chunking so the browser stays responsive during 500–1000 episode runs
- —Trajectory logging and JSON export for future imitation learning or replay work
- —Vitest test suite covering engine rules, pathfinding, agent behavior, and evaluation correctness
- —Deployed to GitHub Pages, interactive in the browser with no backend
Challenges
Keeping the architecture honest under browser constraints. The game core had to stay decoupled from React and Canvas so the headless evaluator could run the same simulation without rendering. Folding ghost proximity into the A* edge weights, rather than filtering paths after the fact, is what pushed its win rate to 100%.
What I Learned
The Ghost Avoidance agent survived longest on average and never won a game. The Behavior Tree scored highest, A* won every run, and which of those counts as best depends on the objective you pick. I spent about as long designing the evaluation as designing the agents.