Posted January 08, 2025 by Pretzel Logic
#8bit #Commodore64 #NPC #Artificial Intelligence
The Pretzelves is a one- or two-player game for the Commodore 64 where two "Pretzelves" skates around an ice rink and collect presents in different colours (that magically appear on the ice for some short time) according to their respective "wish list" of colours. The presents must be thrown into the player's "Santa sack" to make it count. There is also a set of other items and obstacles that appear randomly on the ice. A more detailed text on this can be found here: Making the Pretzelves Come Alive
When the idea for The Pretzelves first came up, the main focus was a two-player game with "skating elves throwing snowballs and catching Christmas presents," a game you could play with friends and have a nice time.
As the development progressed and the game idea got clearer, the question came up of what to do with those playing alone. One idea was to have a one-player mode where the player only competes against the clock was proposed, but as a programmer, there is a challenge in making a computer-controlled player that gives the human player(s) a nice, balanced, challenge.
The player controls are essentially divided into three steps:
This makes it easy to simply replace the first step from reading a joystick to getting the desired direction from an AI instead - the rest of the player movement will be handled in the same way regardless.
Since the computer player "wins" if the time runs out, the main goal could have been to just obstruct the opponent, but that would not make the game much fun. Instead, the following goals are used:
To achieve this, the following states were initially implemented:
The navigation is simply a target coordinate (the wanted present, the opponent, or a point near the own Santa sack) and adjusting the direction to go to that target. The only exception is the rink with an "island" in the middle, where the computer Pretzelf always tries to go the nearest way around the "island".
These few states and in a way quite simple behavior turned out to make a formidable opponent, and it was really hard to win even on the very first level, so some dumbing down had to be done.
These additions made it possible to adjust the "cleverness" of the computer Pretzelf and make it, in a way, more human - we tend to make mistakes every now and then, and by adding the randomness this happens to the computer Pretzelf as well.
Adding a computer-controlled player is always a fun challenge, and the main work is to
a) Decide on a strategy for the computer-controlled player and (in this case) formulate a limited set of states that is manageable but still gives a decent amount of variation in behavior
b) Make the behavior "human" in some way. Adding randomness to some of the parameters controlling the player is one way that is feasible even in the limited world of old 8-bit computers.
Hopefully, this reading will give You an extra dimension for thought when playing the game.