Inside the code of Google’s Pac-Man Doodle

Inside the code of Google’s Pac-Man Doodle

By Mark Sabbatini

So how do the ghosts decide to chase in a two-player game?

Programmer Marcin Wichary says he had lots of help translating most elements of Pac-Man’s original source code into a playable Google logo that set off a frenzy – and fury – for 48 hours starting March 21. But a drastically different maze, the option of having two people play at once and certain quirks in the original made a number of judgement calls inevitable.

Since the ghosts’ behavior and speed is based partially on dots Pac-Man consumes, how do you adjust those factors in a maze with more dots? Do you preserve the original’s bugs, including the famous game-ending “kill screen” on the 256th level – and is something really a bug if deliberately included?

Google’s Pac-Man was programmed by Wichary with graphics artist Ryan Germick designing the logo known as a Doodle. It’s the first interactive Doodle by the company and was released as a tribute on the 30th anniversary of what at the time was the world’s most popular arcade game. Buzz from the Doodle was enormous, topping the most-read list of newspapers worldwide, causing what countless companies said were massive decreases in worker productivity and incensing plenty confronted with the game’s familiar siren soundtrack anytime they were near a computer.

(Although the Doodle is no longer on Google’s homepage, it can still be played online or downloaded. Instructions are at the end of the article.)

The Doodle follows nearly all of the parameters of the coin-op original’s normal difficulty setting in terms of player/ghost speeds, energizer vulnerability times and ghost artificial intelligence. Perhaps the most significant gameplay change – the two-player option – is dealt with in a simple manner.

“Any given time a ghost exits a pen, it will focus its attention randomly on one of two players, and proceed as if the other did not exist,” Wichary wrote in an e-mail interview. “I thought it was a simple solution that perhaps would’ve been implemented in the original Pac-Man under similar circumstances.”

The ghosts retain their chase personalities from the original regardless of the number of players, so Blinky targets a player’s current position while Pinky focuses on a spot two Pac-lengths in front of the direction the player is facing (except when they are energized or retreating to their home corners at specific intervals). That, along with ghosts having to patrol a larger maze, makes a two-player game considerably easier than the original.

Beating or bonding with your human opponent is, of course, another matter.

“What floored us was how well the game translated to the two-player mode,” Wichary wrote. “You can play cooperatively, but if you want to compete, the ghost pointing scheme, for example, is brilliantly conceived: catching the last frightened ghost will net you more points than three previous combined, so you need to strategize when competing against the other player.”

The Google maze has 275 dots compared to the original’s 240, plus an extra energizer in the dead-end capital “G” in the logo. Ghosts emerge from their center pen and increase speed after a certain number of dots are consumed (the exact numbers decrease by level and can also be affected by the amount of time elapsed), but Wichary said he “didn’t make very many changes” in the Doodle version.

“Since some of the original logic counts dots from 0, and some from the max (275 in our case, if I remember correctly), we thought the original numbers should hold up really well,” he wrote.

One change that has a modest visual and strategy impact is the ghosts’ pen is well to the right of center, which Wichary said was an aesthetic necessity.

“We needed to have GOOGLE on the playfield, given our doodle tradition,” he wrote.

Gameplay in the original is largely governed by an invisible grid where each square is one-fourth Pac-Man’s size. That allows for certain quirks such as ghosts being able to touch Pac-Man without killing him and the rare possibility of passing completely through a ghost (the latter must happen during a specific 1/60th of a second interval). The same logic, and thus the same behaviors, exist in the Doodle.

The “kill screen,” which exists in the original due to the inability of the eight-bit level counter to count beyond 255, can also be found in the Doodle. But Wichary notes it’s “a deliberate effort.”

“Alas, it’s not playable, but the way it’s created is a deliberate homage to the original (it’s done procedurally, not just a pre-rendered image),” he wrote.

One element of imperfection – while not actually a bug – was the Doodle automatically started after 10 seconds if the user took no action and there was no option to mute the sound, resulting in the deluge of infuriated messages on Google’s and others’ comment sites. An update eventually placed a mute button on the screen.

The Doodle is written in a combination of JavaScript, HTML and CSS, with Flash used for sound since, according to Wichary, “HTML5 Audio is not yet ready to do things like that.” That means the game plays (soundlessly) on an iPhone/iPod/iPad, but controlling Pac-Man by touching the maze is less than precise.

Translating the arcade’s Z80 processor code to the modern language of the Web involved a variety of sources.

“We had a lot of help from Namco Bandai, we did a lot of ‘research’ using a Pac-Man machine we actually have at Google, and we looked at (The Pac-Man Dossier),” wrote Wichary, the latter referring to Web document by Jamey Pittman widely considered the definitive analysis of the original’s inner workings. “Hard to tell exactly what goes where, but all three sources were crucial.”

Wichary’s creation, while no longer on Google’s homepage, can be played online by going to the company’s Doodle archive at www.google.com/logos.

It can also be downloaded from a number of locations, including www.underealm.com/download/GooglePacman.zip. But it will play without sound unless the user makes an adjustment online to their Flash Control Panel. The site is at www.macromedia.com/support/documentation/en/flashplayer/help/settings_manager04.html. The user selects “Edit Locations,” then “Add Location,” then “Browse for Folder.” When a dialogue box appears, select the folder the Doodle was extracted to.

The Pac-Man Dossier is at http://home.comcast.net/~jpittman2/pacman/pacmandossier.html.

VN:F [1.9.16_1159]
Rating: 0.0/10 (0 votes cast)
Similar posts plugin not found.
Comments are closed.