<ARYA/>
← All projects

2026

Pac-Man AI

Browser-playable Pac-Man with comparative AI agent evaluation

TypeScriptReactViteHTML CanvasA*Behavior TreesQ-LearningVitestGitHub Pages

Overview

A browser-first Pac-Man project built as both a playable game and an AI portfolio piece. The goal was to take a classic arcade loop everyone understands, rebuild it on a clean deterministic game core, and use it as a controlled sandbox for comparing decision-making strategies — from random baselines to pathfinding and behavior trees — directly in the browser.

The Problem

Most AI game demos are either toy scripts with no real architecture, or heavyweight ML setups that are hard to run and harder to compare. This project sits in between: a fully 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

Designed and built the entire system solo — game engine, rendering pipeline, controller abstraction, all five AI agents, headless evaluation system, trajectory logging, and the Reports UI 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 — runs hundreds to 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 — fully interactive in the browser with no backend

Challenges

Keeping the architecture honest under browser constraints. The game core had to stay fully decoupled from React and Canvas so the headless evaluator could run the same simulation without rendering. Getting the A* agent's danger-aware path cost right — folding ghost proximity into edge weights rather than post-hoc filtering — was the key design decision that pushed its win rate to 100%.

What I Learned

Evaluation design matters as much as agent design. The most revealing result was that the Ghost Avoidance agent survived longest on average but never won — living longer is not the same as clearing the board. The Behavior Tree's highest average score and A*'s perfect win rate tell different stories about what "best" means depending on the objective.