Sep 24 A Perfect Game of Pacman

Pacman is one of the best known computer games from the era of arcades. You start of with six lives before you have to start again by feeding in another quarter. The levels are all fairly similar with lots of dots to eat, as well as occasional fruit that pops up for bonus points and four special power ups that temporally give you the ability to eat the ghosts which are chasing you.

The game has a finite number of levels due to a glitch. After level 255 you end up on a weird half level which looks like this:

Glitchy

The level counter was only programmed with 8 bits of data; 255 fits in because it is 11111111 in binary. 256 would need a ninth bit and so instead clocks over to being 00000000. Because all of the level generation is done from the level number this resetting to zero messes it up.

Because there are only 256 levels there must be a theoretical top score; theoretical that is until Billy Mitchell managed to achieve the perfect score of 3333360 in a six hour long marathon game back in 1999. Since then another five people have matched the feet and the current world record is under four hours. To get this score you need to get all of the dots and every piece of fruit on every level. You can't lose any lives and you have to eat all four ghosts every time you power up. Let’s look at the numbers. Firstly there are 240 regular dots on each level worth 10 points each, plus 4 power ups with 50 each. This gives 2600 points, so 2600x255=663000.

Eating ghosts nets 200 for the first and doubles for each subsequent ghost, so 200+400+800+1600=3000. Four powers ups per level makes 3000x4=12000. However as the levels go on the ghosts blink for less time until eventually you can't eat them at all. On level 17 and levels 19 onwards you can't get these bonuses so 12000x17=204000.

Fruit is slightly weirder, but it appears twice on each level and the amount you get depends on which type of fruit it is, which in turn depends on the level number, but they are roughly worth more as you go along. In total you can earn 2459600 from the fruit of which most of the value comes from the key which is worth 5000 and appears in levels 30 onwards.

So far this only adds up to 3326600 which is still 6760 short of the perfect score from the normal 255 levels. The final level has a fairly normal left side where 112 regular dots and 2 power ups are showing plus you can get the fruit once (and only once on just this level), so we have 112x10+2x50+5000=6220. 540 to go.

In the glitched left side there are 9 hidden dots that can't be seen. Every time you die they respond,  so if you have all of the extra lives left from earlier then you can collect them a total of 6 times for 6x90=540.

Clearly playing for multiple hours is a hard feet, but there is a helpful bug. There is one place in the maze where the ghosts will never find you, pictured below. This allows for breaks to eat and go to the toilet.  When you are perfecting the strategy it is worth knowing that each ghost has a different programme behind it. Blinky (red) tries to head you off and is the most dangerous. He gets quicker when there are only a few dots left and prefers the top right.

The pause spot

Pinky (pink) likes to follow you and will be on you tail. If you head straight at him he will turn off and try to travel parallel to you. Inky (blue) actively runs away from you and is the least dangerous, but you can occasionally run into him. Finally Clyde (orange) wants to get generally near you but not actually catch you. Now try to imagine managing to catch all four four times in a row for 17 levels. Very hard, but you will be surprised at how many blogs are dedicated to the goal.

However all of this knowledge is only used in practice if you go off book in your play. Instead of trying to improvise their way through hundreds of levels, where you will inevitably make a mistake at some point, the aspiring top scorers try to follow preplanned patterns. Because the movements of the ghosts are deterministic, if you move in the same way on a particular level then so would the ghosts. Watching them follow these patterns is surprisingly hair-raising as Pacman veers within a pixel of ghosts.

I was reminded of the infamous final level of Pacman b the audio book of Ready Player One. It is packed with references to 80s arcade games and I thoroughly recommend it.