Pacman Ai
I wanted to feel the difference between agent designs, not read about it. So I forked a JavaScript Pac-Man and wrote three agents against the same game: a rule-based agent with only two rules, a utility-based agent that…
I wanted to feel the difference between agent designs, not read about it. So I forked a JavaScript Pac-Man and wrote three agents against the same game: a rule-based agent with only two rules, a utility-based agent that scores candidate moves, and a learning agent that improves with play.
The question that shaped the project: which approach holds up? One good game proves nothing. Answering it takes hundreds of runs, and watching games render in a browser is far too slow. So I built a headless mode: a Node CLI that runs simulations in parallel without rendering, prints per-run metrics, and can save recordings as JSON. A replay page loads those recordings, which means I could study failure cases after the fact instead of trying to catch them live. There's also a small local server with a UI for browsing headless runs.
The comparison played out the way theory says it should, and that was the point of building it. The rule-based agent is readable and predictable but brittle: situations its two rules don't cover end badly. The utility agent generalizes better because scoring moves handles situations nobody anticipated. The learning agent needs long runs before improvement shows, which is the cost you pay for not hand-coding behavior.