Prog 1: Wumpus
(fixed size array)

Description


Welcome to Hunt the Wumpus, a classic text-based adventure game by Gregory Yob from 1972.


(See a copy of his original write-up, and the Wikipedia page. Play a text-based copy on-line. See what one version of this program looked like in BASIC.)


The Wumpus lives in a completely dark cave of 20 rooms. Each room has 3 tunnels leading to other rooms, as indicated in the diagram shown at right:

Note that this program will be developed over the course of the semester and turned in as three separate versions, as described on the course schedule:

  1. Using a fixed sized array, without superbats or arrows. The point of the game in this version is to guess which room the Wumpus is in.

  2. Using a dynamically allocated array, implementing superbats and arrows. The point of the game in this version is to shoot an arrow to kill the Wumpus.

  3. (later in the semester) Same functionality as previous version, implemented using dynamic memory and pointers for rooms.

Because you will be retooling your code to implement future versions, be reflective on how you write it. In particular consider separating the interface from the underlying data implementation. The interface itself will be the same across all versions, even though earlier versions may not implement some features. Our version will vary from the original, to make it easier to test.

Running the program looks like the following:

Implementation Details:

(Features implemented by grayed-out text should not be included until the next version.)
Implement the game using the following steps and requirements. User input should be accepted as either upper or lower-case. I suggest that within your program you convert user input to upper-case, to make coding easier.

  1. Implementing the cave system, allowing making moves from room to room. Note you can implement this using arrays, vectors, lists, or whatever way makes sense to you. No points will be awarded for this program unless you can at least make moves throughout all the rooms. Attempting to move to an invalid room gives an error message and allows the user to retry.

  2. Initializing the game to have the Wumpus in some random room, the bottomless pits in two other rooms, and super-bats in two other rooms. These 5 rooms with hazards must all be distinct from one another. Place the person into an initial random room that contains no hazards.

  3. Implement the 'C' option to cheat and display the locations of hazards, the person, and the arrow. This will help you test your program, and will help us test it as well.

  4. Implement the 'R' reset option to set the values of the person, arrow, and all hazards. This will help you test your program, and will help us test it as well.

  5. As you move through the maze, if you enter a room with an arrow you automatically pick it up.

  6. As you enter each room indicate what is present:

      • If this room is next to the Wumpus room, give the message: "You smell a stench."

      • If this room is next to a room with a pit, give the message: "You feel a draft."

      • If this room is next to a room with bats, give the message: "You hear rustling of bat wings."

  7. When you enter a room with the Wumpus in it, if that room is odd-numbered then the Wumpus will move to the lowest-numbered adjacent room. Else it will snap your neck and the game is over!

  8. Implement the super-bats dropping you into a random new room, then relocate those bats to some random room different from the person, the other bats, or those bats' original room.

  9. Implementing the 'S' option for shooting the guided arrow 1 to 3 rooms. Your first input is the number of rooms, followed by the rooms themselves. If a room number is not adjacent to the current arrow location, then the arrow will ricochet to the lowest-numbered adjacent room. Remember that anytime you shoot an arrow, the Wumpus will move to the lowest-numbered adjacent room, regardless of what sort of room the Wumpus is currently in.

Below is a list of the various program messages that should appear, and the conditions under which they appear. You need to know these and copy them exactly as shown so that your output matches the expected output. The ones highlighted in red have to do with hazards (bats, pits, Wumpus). Those in yellow have to do with the arrow. Those in green have to do with displaying cheats and resetting hazard values, to help in testing.


Prog 1 Wumpus Messages

So that your output matches the expected output, your program must handle things in the following order:

  • When setting random locations for various game components, assign them in the following order:
    bats1, bats2, pit1, pit2, Wumpus, person

  • Each time you choose a random destination for one of the game components, you must ensure that it is not already being used by some other component. If it is, then generate a new random room to try.

  • When checking adjacent rooms to display whether or not hazards are present:

        1. Check adjacent rooms in ascending numerical order.

        2. First check for Wumpus, second check for pits, third check for bats, respectively displaying messages when any of these are found. Having this explicit order is necessary so your output matches the expected output when multiple conditions are present.

  • When moving into a room, check for hazards in the following order:

  1. Check for a pit. If it is there, you die.

  2. Check for the Wumpus. If it is there, and the room is odd-numbered, then the Wumpus moves to the lowest-numbered adjoining room, else the Wumpus kills the player.

  3. Check for bats. If present, they move you to a random new room

    • This version of the game makes some non-random decisions, to help with testing the program. If you want to make a version playable by your friends (which you don't turn in!), then make the following changes:

        1. When the Wumpus is awakened, currently if it is in an odd-numbered room currently the Wumpus moves to its lowest-numbered neighbor.
          Change this so that when the Wumpus is awakened, it moves to a randomly-selected adjacent room 75% of the time, and stays where it is (and kills the player) 25% of the time.

        2. Arrows that ricochet currently move to a room's lowest-numbered adjacent room.
          Change this so that when the arrow ricochets, it moves to a randomly selected adjacent room.

Test Cases

(Features implemented by grayed-out text should not be included until the next version.)
The following sixteen test cases cover various output messages and many of the game conditions. Each test case is worth between 2 to 6 points as follows:

Prog 1 Wumpus Messages

Extra Credit (Likely only for 3rd version)

Up to 6 points of extra credit can only be earned if all other aspects of the game are working and it is turned in on time. Your normal submission should not have the extra-credit portions in it. Earn extra credit by making ASCII animated splash screens for all three of the following:

  1. The beginning of the game

  2. When you kill the Wumpus

  3. When you die trying.

To make ASCII animated splash screen print the contents of the screen, then clear the screen (system("clear"); on UNIX), then print another slightly different screen, and so on. (See samples of Star Wars, and an amazingly artistic dance, and see this recap of a book on how Victorian stenographers started typewriter art, or this rolling donut). To get extra credit your splash screens must be unequivocally interesting and represent significant effort.


Turn in your extra-credit submission ...