Posted May 09, 2022 by Pretzel Logic
#ai #pac-man #Commodore64 #coding
Munchkin was released in 1981 for the Magnavox Odyssey 2(a.k.a Philips Videopac G7000) console, and was a very popular clone of Pac-Man.
There are a couple of features that sets Munchkin apart, for example:
Munchers in the original game
When porting a game to a new platform, as is the case with Munchkin, You usually want to keep things as close to the original as possible.
For Pac-Man it is well known (and documented) how the ghosts are moving and why. The three Munchers have - to the best of my knowledge - not had their behavour documented in any way, and while playing the original game I could not really find any pattern to their movements.
Asking around, everyone seemed to agree that the Munchers move randomly around the maze, so that was the approach used in my port to Commodore 64. Now, in code - and especially when dealing with older, limited, computers - random will always be pseudo random one way or another, and the random in my code will therefore be different from the random used in the original game.
As a result, the Munchers in the port will not behave exactly as in the original, and one thing I noticed was that Munchers needing to go to their "home base" to regenerate after being munched, could take forever. Top remedy this I added the condition that if they are next to the homebase, they will always try to enter it.
That's about it for porting the original game, though I still have a feeling that the Munchers in the original seem to have some sort of cunning plan going on.
The arcade version
Now, another idea I had when starting out with my port of the game was to add an extended version. The original game (as most games on that console) only gave the player one life - that was it. I wanted to expand on the original game to make an "arcade version":
As it turned out I also added other challenges for the player such as bombs occuring randomly in the maze that Munchkin has to eat before they explode, keys to unlock areas of the maze, and a few more challenges along the way.
Making the Munchers scary
I decided to make the AI pretty straight forward:
Each Muncher use one of the two first strategies, and which Muncher using which strategy changes during the game play.
When the game begins, the Munchers are mostly moving randomly and only use its locating algorithm 25 % of the time they select which way to go. This percentage increase during the game until the locating algorithm is used 75 % of the times. Higher than that made the game both very difficult, but also the enemies a bit too artificial for my liking.
Now, while these rules are quite simplistic, they still make for some interesting behavour of the Munchers. For instance it occasionally appears that the Munchers co-operate to hunt down Munchkin with one Muncher hunting and another one intercepting - effectively cornering the player.
Another noticeable instance is when the player has died and is invincible for a few seconds when re-spawned at the center. The Munchers movement is totally random during this period, but as soon as the player is vulnerable again the Munchers starts their hunt/intercept pattern, and it looks like (depending on the probability) insects homing in on a target.
All in all, sometimes a relatively simple AI really is all it takes to give the player a good challenge.