How Pacman Coolmath Actually Works Under the Hood
I've spent more time than I care to admit reverse-engineering browser-based arcade games, and Pacman Coolmath is a good case study in how much you can do with surprisingly little code. The game runs entirely client-side using HTML5 Canvas and vanilla JavaScript. There's no server involved in the actual gameplay loop, which means everything—ghost AI, collision detection, score tracking—happens on your machine. That's both a feature and a problem, depending on what you're trying to do. Coolmath Games hosts a browser clone of the 1980 Namco arcade classic. The page at coolmathgames.com typically routes to it through their game catalog, though the exact URL structure has shifted over the years as they reorganize their domain. The game itself is a faithful recreation with the standard four ghosts (Blinky, Pinky, Inky, and Clyde), the maze layout from the original, pellets, power pellets, and the fruit bonuses that appear on certain levels. It plays identically to the arcade version in terms of ghost behavior patterns and dot collection mechanics. People search for this game for three reasons: nostalgia, trying to find a working clone after the original site went down, or looking to modify it. The third group is the one I tend to help the most.
The code is not obfuscated. If you open DevTools and inspect the page source, you can see the JavaScript files loading. They're usually minified, but readability isn't a barrier. I've pulled the source from the cache when Coolmath was doing maintenance and rewrote small pieces of it to fix bugs in older browser versions. That's worth knowing if you're planning to tinker with the game.
The Technical Details Most People Skip
Here's what nobody tells you about Pacman Coolmath: the ghost AI is not random. Each ghost uses a distinct targeting algorithm. Blinky targets Pac-Man's current tile directly. Pinky targets four tiles ahead of Pac-Man's movement direction, which sounds simple but creates that notorious corner ambush behavior. Inky uses a complex vector calculation that references both Blinky's position and Pac-Man's heading—this is the ghost that's hardest to predict. Clyde switches between targeting Pac-Man and running away based on distance, flipping at roughly eight tiles apart. The scatter mode and chase mode switching happens on a timer. In the original, the intervals are 7 seconds scatter, 20 seconds chase, 7 seconds scatter, 20 seconds chase, then it locks into chase mode permanently. The Coolmath version preserves these timings. If you're speedrunning or trying to memorize patterns, knowing the exact switch points matters because the ghosts become significantly easier to play through during scatter phases. There's also the issue of ghost release timing. The ghosts start in the pentagon house in the center of the maze. Blinky releases immediately. The others release on a staggered schedule that corresponds to the number of pellets remaining. This is why early game strategy involves eating dots quickly to keep the ghosts released rather than letting them pile out all at once.
Get the Full Details

A Real Problem I Hit and How I Fixed It
Last year, a student was trying to use the Pacman Coolmath game for a programming assignment where they had to modify the ghost AI to make it harder. The problem was that the game loads its JavaScript from Coolmath's CDN, and when the page cached an older version of the script, the modifications I'd tested stopped working. The game appeared fine but the ghost behavior was unchanged. I couldn't tell at first whether the edits weren't applying or if something else was overriding them. The fix was to intercept the game in a local environment. I downloaded the page source, pulled the JS files to a local directory, and served it through a simple HTTP server instead of loading from the CDN. That way, any changes I made were guaranteed to load. I also added a console.log statement at the top of the ghost AI function to verify which code path was actually executing. Turns out the cached version was serving the old script, and the browser was happy to use it without complaint. This came up again six months later when Coolmath updated their domain structure and the game moved to a different subdomain. The same caching issue, same solution. If you're modifying browser games for a project, local hosting isn't optional. It's necessary.
What This Game Can't Do (And Where It Breaks)
The most important limitation to understand is that Pacman Coolmath is not a robust source code repository. The JavaScript is minified, sometimes bundled with other games on the same page, and occasionally updated without notice. If you're relying on specific variable names or function structures for a hack or a mod, those can change and break your work without warning. There's also no save state functionality built into the game. If you want to record progress, you have to implement it yourself by hooking into the game loop and serializing the state object. I've written a basic state serializer for this that captures position, score, lives, ghost modes, and pellet status. It outputs JSON that you can load back into a modified version of the game. This works reliably across Chrome and Firefox but has edge cases in Safari where the canvas rendering order differs slightly and ghost collision frames can desync by one tick. The game also doesn't run correctly on mobile in most configurations. The touch controls are an afterthought at best, and the maze is too dense for typical phone screens. I've seen people try to scale it with CSS transforms, but the hit detection breaks because the canvas coordinates don't map linearly to the visual scale. A proper mobile version would need the maze simplified and the touch input remapped to directional swipes with a larger hit area.
How to Access It
The game is available on Coolmath Games' website. Navigate to coolmathgames.com and search for Pacman in their catalog. The URL has changed over the years, so a direct link isn't reliable. If the main site is down, archived versions exist through the Internet Archive's Wayback Machine, and the source code can be pulled from there if needed. For local development, I'd recommend setting up a simple project structure with a copy of the HTML, JS, and any asset files, then using a tool like Live Server in VS Code or Python's built-in http.server to serve it. This gives you full control over what loads and makes debugging significantly easier than working through DevTools alone.

The Counter-Intuitive Part
Most people assume the Pacman Coolmath version is a straight port of the original. It's not exactly. The frame timing has been adjusted for modern browsers, which means the ghost movement feels slightly smoother but also slightly different from the arcade. The pellet count per level is the same, but the fruit spawn timing can drift depending on your browser's requestAnimationFrame implementation. If you're comparing scores across versions, the variance is usually small but measurable over multiple playthroughs. Another thing that surprises people: the ghost fright mode timer is not consistent. It starts at 7 seconds and halves each time a ghost is eaten during fright mode, down to a minimum of about 2 seconds. This is preserved from the original, but in the browser version, the countdown can stall if the tab loses focus. Chrome throttles requestAnimationFrame in background tabs, which slows the game loop. The ghosts still move, but at a reduced frame rate. This is actually a useful trick for casual play but ruins any attempt at consistent speedrunning. The game is free, runs in any modern browser, and the source is accessible. It's not perfect, and it's not going to replace playing the real arcade cabinet, but for what it is, it works well enough that I keep coming back to it when I need a quick reference implementation of classic arcade AI patterns.