I’m not going to say that famously Ms. Pac-Man is a more random game than Pac-Man, because who really knows things like that who isn’t a hardcore gamenerd. But among hardcore game nerds, it’s common knowledge. (If you didn’t know, A. congrats on your coolness, and B. sorry to now destroy your coolness.) Here a video about how randomness works in that game, from Retro Game Mechanics Explained (21 minutes):
Pac-Man is a game that is vulnerable to patterns: if you do exactly the same thing each time on the same level, the same results will occur. There is one pseudo-random element in Pac-Man though: when vulnerable ghosts reach an intersection, the code picks an arbitrary address from a range of memory addresses, then uses that value to pick a direction to decide which route to take. Two implications of this: vulnerable ghosts are most likely to head left at intersections and least likely to go up, and if any byte in that range changes the behavior of the game slightly changes too, even if it’s not an executable byte. Patterns still work in Pac-Man, despite this pseudo-random function, because the seed is reset at the start of every level, so if you do exactly the same thing, vulnerable ghosts will still have the same information fed to their movement routines.
Ms. Pac-Man has other sources of randomness: the ghosts, in Scatter mode, use a different source of pseudo-randomness to decide where to go, one that isn’t so easy to manipulate; and which fruit appears and which of four predefined routes (three for one of the mazes) it’ll take through the board.
Ms. Pac-Man doesn’t have its ghosts scatter periodically through the level like they do in Pac-Man. They only scatter at the start of the board. It’s not much randomness, but it’s enough to upset rote pattern creation, since each ghost has the opportunity to make several decisions of which path to take during that period. The way the randomness is handled is interest itself. The ghosts pick one of the corners of the board, much like they would in original Pac-Man, but randomly, when making their choice of target to home in on.
So there! Now you can amaze your friends, if it were 40 years ago and your friends were then able to be impressed by your knowledge of Ms. Pac-Man! You’re retroactively welcome!
I did a search of the blog to make sure I haven’t posted this before. I’m really an obsessive tagger, and it didn’t show up under the tag pacman, so I think it hasn’t been seen here before. Let’s fix that now!
It’s a video from Retro Game Mechanics Explained from six years ago, and it’s 11 1/2 minutes:
Here’s a terse summary of the explanation, that leaves out a lot. Like a lot of 8-bit games (the arcade version uses a Z80 processor), Pac-Man stores the score in one byte, making the maximum it can count to 255. Since it doesn’t use signed arithmetic, it doesn’t use the high bit to signify a minus sign and so flip to negative at 128.
As an optimization, Pac-Man’s code uses the depiction of the maze in the video memory, itself, in the movement of both Pac-Man and the ghosts. If a spot has a maze wall tile, then Pac-Man can’t go there, and the ghosts won’t consider that direction when moving.
At the start of every level, the game performs some setup tasks. It draws the maze anew, including dots, Energizers and walls. One of these tasks is to update the fruit display in the bottom-right corner. It was a common design idiom at some arcade manufacturers, especially at Namco, at the time to depict the level number with icons in some way. Galaga shows rank insignia in the corner; Mappy has small and large balloons and mansions.
Pac-Man’s code shows the bonus fruit for each level, up to seven of them. If you finish more than seven levels, only the most recent seven are shown. If you get far enough eventually this will be just a line of Keys, the final “fruit.”
The code draws them from right to left. There’s three cases (the video goes into much more detail), but generally it starts from the fruit of six minus the current round number, draws it, counts up once and moves left two tiles, draws that one, and so on.
An interesting fact about Pac-Man’s graphics hardware is that the screen doesn’t map as you might expect to the screen! A lot of arcade games have weird screen mappings. Most consumer programmable hardware will map characters horizontally first vertically second, like a typewriter*.
In Pac-Man, the bottom area of the screen comes first in memory, starting at memory location hex $4000 (16384 decimal), and it doesn’t go forward like an English typewriter, but is mapped right to left. The first row of 32 tiles comes at $4000, and the second row is $4020. Then the playfield area is mapped completely differently, in vertical rows going down starting from the top-right of its region, then the next vertical row is the one to the left of that, and so forth to the left edge of the playfield. Then comes the score area at the top of the screen, which are two final rows mapped the same way as the bottom area, right to left.
When Pac-Man’s score counter overflows, it breaks the check for the limit for only drawing seven fruit, and causes it to draw 256 fruit. This is why the tops of keys are drawn beneath the upper-halves of the fruit at the bottom of the split screen. It also breaks the tile lookup for the fruit.
As it continues writing its missourced fruit tiles in memory, it goes back in memory each time to draw the next fruit, and after the fruit section of the display it keeps going to the left, into the area where Pac-Man’s lives are displayed, then it keeps going and overwrites half of the maze tiles. Then Pac-Man’s lives (and any empty spaces that indicate the lack of lives) are plotted, overwriting fruit after the first ones drawn and obscuring some of the memory corruption.
Since the game’s actors use that data to decide where to move, and where dots and Energizers are placed, it means they can move outside the bounds of the maze, and that there won’t be enough dots for Pac-Man to eat to complete the level. That’s what makes it a kill screen: if Pac-Man loses a life, a few dots will get placed in the maze as the fruit are redrawn, but it’s not enough to bring the dot-eaten count to 244, which triggers the level clear function.
If the fruit-drawing loop didn’t stop at 256 (another artifact of using 8-bit math for the loop), it’d go on to clobber the rest of the maze, the score area at the top of the screen, then color memory (which has already been clobbered by the palette-drawing portion of the loop). Then, going by a memory map of the arcade hardware, it’d hit the game logic RAM storage, which would probably crash the game, triggering the watchdog and resetting the machine.
The visual effect of the split screen is certainly distinctive, enough that since Bandai-Namco has capitalized on its appearance at least once, in the mobile (and Steam and consoles) game Pac-Man 256. I’ve played Pac-Man 256: it’s okay, but, eh. It’s really too F2P unlocky.
* Yes, I just used a typewriter’s operation as a metaphor for something a computer does. It didn’t feel acceptable to use another computer thing as the comparison, since ultimately the reason they do it that way is because typewriters did it that way too. I guess the fact that it’s English reading order would be better to use, but I’m really overthinking it at this point.
Let’s get the video embed out of the way first. Pow!
Super Mario Bros. 3 has two significant minigames (outside of two-player mode), and the inner workings of both are explained in this video.
In most worlds there are “Space Panels,” which provide a slot machine minigame for extra lives. If you’ve ever tried them, you might have noticed that it’s extremely difficult to win anything at it. Well, the video explains why that is: there’s a significant random element to stopping the wheels. In particular, the last wheel has so much randomness in when it actually stops that it’s actually completely random what it’ll stop on! So much for timing!
I have a theory (which I explain in a comment on that video) that the slot machine game was made so random because of the quality of the reward (it’s possible to earn up to five extra lives at it), and because they had played around with life-granting minigames before. Doki Doki Panic, which got reskinned for overseas markets at Super Mario Bros. 2, has a slot machine game, “Bonus Chance,” that appears after every level. With good timing and practice Bonus Chance can be mastered, earning up to five extra lives for every coin plucked in the level. I have managed to abuse that game to earn so many extra lives that the game ran out of numbers for the tens’ digit of the life counter, sending it into letters of the alphabet. There’s certainly no danger of that in Super Mario Bros. 3.
The second minigame has the player match cards from a grid of 24. Each pair of cards found earns a modest prize, from as little as 10 coins up to a single extra life. Most of the awards are powerups for the player’s inventory. The player gets two tries, but if they don’t clear the board it’ll carry over to the next time they play. Attempts at the card matching board appear every 80,000 points the player earns, making it the only Super Mario game to actually reward scoring lots of points.
The card matching game is one of the most interesting minigames in all of the Mario series. There’s only eight layouts for the cards, the second and fifth cards of the middle row are frequently both the 1UP card, and the last three cards on the bottom row are always Mushroom, Flower and Star, in that order. This means the minigame can be mastered, and even if you don’t memorize all eight layouts to deduce where the prizes are, knowing the three cards that never change usually means it won’t take more than two or three attempts to clear the board, netting lots of powerups.
Retro Game Mechanics Explained looks into why the card matching game works the way it does, and discovered some interesting things. There’s actually code in the game to do a much more thorough randomization of the cards, but it goes unutilized. The full details are in the video, but in summary:
The board always begins in the same state,
the last three cards on the bottom row are left unchanged, probably on purpose,
the first way the other cards are scrambled shifts them one space in sequence, and is only done one or three times, three times in total,
and the other method of scrambling them, which involves swapping around three specific cards, is done exactly once between each shift.
The only variation in the steps is from the choice of whether to shift once or thrice, each of those three times. Thus, there are only 23 possible layouts, that is, 8. There is a loop in there to potentially vary the number of times the cards are swapped (the second way to scramble the cards), but the way it’s written the loop is never used, and the cards are swapped only once each time.
What I also find interesting is, this isn’t the only Nintendo to use a minigame that involves mixing up hidden prizes. Kid Icarus’ Treasure Rooms also have a limited number of layouts, which vary for each of the game’s three worlds. The player can open pots in the room to collect minor items, but if they open the wrong pot early, before opening all the others, they find the God of Poverty, and lose everything they’ve found. If they can save that pot for last, though, the final pot will instead contain a pretty good prize, which can even be a Credit Card item that cannot be obtained otherwise.
The way they’re designed, both Mario 3’s card-matching game and Kid Icarus’s Treasure Rooms have tells, specific spots that can be revealed to identify which of the limited number of boards that version of the game is using, and that the player can use to get all the prizes. Also, there are Nintendo-published guides that reveal all the layouts, in Nintendo Power for Kid Icarus (recounted on this charmingly old-school webpage), and the Nintendo Power guide for Super Mario Bros. 3 (on page 10), so Nintendo had to have been aware of the limited nature of the board layouts, and may have actually intended them to be defeated with a good strategy.