Hunt the Wumpus

Original Wumpus artwork
The game Hunt the Wumpus isn’t difficult to code in C. In fact, all you need do is start with the basic number-guessing game presented in last week’s Lesson and you can build just about any text-mode game. That’s what I did when I started my own C language version of Hunt the Wumpus.

Historically speaking, Wumpus was one of the first (if not the first) best-selling computer game. Written by Gregory Yob in 1973, it was was available for the various microcomputers of the era. In fact, I recall a version available for my ancient TRS-80 Model III, which I purchased in 1982. (Wikipedia Entry, Hunt the Wumpus)

The game is text-based. You read a description and type commands based on the description. In this game, the player is trapped in a cave or labyrinth of rooms. Each room is connected to three other rooms. The player moves between the rooms in an effort to hunt and kill the mysterious wumpus.

In addition to the wumpus, the labyrinth is populated with two giant bats and two bottomless pits. Entering a room with a bat causes the bat to lift you up and fly you to another, empty room in the labyrinth. Entering a room with a bottomless pit causes you to die, ending the game. If you’re unfortunate to enter a room with the wumpus, you’re eaten and, of course, die.

Fortunately, the game provides feedback when you’re near a room with the wumpus, a bat, or a pit. Here’s the text output:

If a bat is in a nearby room, the message is: You hear a rustling.
If a bottomless pit is in a nearby room, the message is: You feel a cold wind blowing from a nearby cave.
If the wumpus is nearby, the message is: You smell something terrible nearby.

Upon sensing the wumpus, you can fire an arrow into one of the three rooms. If you guess the room correctly, the wumpus is killed and you win the game. If you guess incorrectly, the wumpus has a 75-percent chance of fleeing to another random room in the labyrinth.

Programmer Yob designed the labyrinth to be more interesting than the grid patterns of early computer games. He chose a layout based on a dodecahedron, or 12-sided shape (Figure 1). The rooms are still interconnected, so it’s possible to navigate forward and background through the rooms in a predictable manner.

Dodecahedron animation

Figure 1. Animation of a dodecahedron, stolen from Wikipedia. The rooms in the Wumpus labyrinth are based on the shape’s vertices.

The original Hunt the Wumpus was written in BASIC, which was common in the early days of computing. I vaguely remember playing it back back then, though it’s simplistic and gets old quickly. Still, Wumpus provided the basis for other, more complex and involved text-mode games, such as Adventure and Zork.

Based on the information I provided in this Lesson, you could begin coding your own version of Hunt the Wumpus. The details presented were all I started out with. Of course, coding the game took a while, mostly to work out the bugs, but also to re-think my approach several times. I cover the specifics in next week’s Lesson.

4 thoughts on “Hunt the Wumpus

  1. I am surprised that Yob is a name. It is also British slang . . .
    When I was at school we had a text game called Hammurabi, who was a Babylonian king. Can’t remember much about it but I recall having to decide how much corn to plant to ensure everyone had enough food the following year. Even in the early 80s it wasn’t wildly exciting.
    The Rosetta Code site you mentioned in your previous post looks interesting, I’ll have to spend some time looking through the projects.
    I have been messing about with WebGL & three.js recently so might try to construct a 3D dodecahedron.

  2. By the way, when I looked at this page this morning the dodecahedron animation worked but now it has disappeared.

    Warning: irritatingly pedantic comment – the vertices are the points where the edges meet, not the surfaces representing the rooms.

  3. I was surprised by “Yob” as well, thinking it might be a pseudonym. Nope. He’s a real guy. Interesting career.

    The vertices represent the connections between the rooms; each room has three paths out. This was explained on one of the Wumpus sites I visited. Having the surfaces represent the rooms would be better; that way each room would have five exits.

    Definitely check out Rosetta Code. It’s marvelous.

  4. I didn’t realise yob was also “American English”. Apparently it is “Americanized spelling of German or Hungarian Job”.

    I think I have finally understood the game. I assumed the surfaces were rooms which confused me as they have five sides but now I get that the vertices of a dodecahedron represent rooms and the edges represent connections between them.

    It might make more sense to use an icosahedron which has 20 triangular faces which could represent rooms, with a door in each side to access the adjoining 3 rooms.

Leave a Reply