Prog 5: Wumpus

11/10 Details (shown in blue) added to give the order of handling events, to help you have your output match mine.

11/13 Assessments added, and described and highlighted near the bottom of this page.  Extra Credit project added to Codio.

11/16 Description changed (shown below in highlighted green) to show that Wumpus always moves when an arrow is shot, regardless whether Wumpus is in an odd-numbered room or not. Input used for each assessment added to the table listed all the assessments.

Welcome to Hunt the Wumpus, a classic 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 this diagram:

Running the program looks like:

      You are in room 13. You smell a stench.          1. Enter your move (or 'D' for directions): d                ______18______               /      |       \              /      _9__      \             /      /    \      \            /      /      \      \           17     8        10     19           | \   / \      /  \   / |           |  \ /   \    /    \ /  |           |   7     1---2     11  |           |   |    /     \    |   |           |   6----5     3---12   |           |   |     \   /     |   |           |   \       4      /    |           |    \      |     /     |           \     15---14---13     /            \   /            \   /             \ /              \ /             16---------------20          Hunt the Wumpus:         The Wumpus lives in a completely dark cave of 20 rooms. Each         room has 3 tunnels leading to other rooms.          Hazards:         1. Two rooms have bottomless pits in them.  If you go there you fall and die.         2. Two other rooms have super-bats.  If you go there, the bats grab you and            fly you to some random room, which could be troublesome.  Then those bats go            to a new room different from where they came from and from the other bats.         3. The Wumpus is not bothered by the pits or bats, as he has sucker feet and            is too heavy for bats to lift.  Usually he is asleep.  Two things wake            him up: Anytime you shoot an arrow, or you entering his room.  The Wumpus            will move into the lowest-numbered adjacent room anytime you shoot an arrow.            When you move into the Wumpus' room, then he wakes and moves if he is in an             odd-numbered room, but stays still otherwise.  After that, if he is in your             room, he snaps your neck and you die!

       Moves:         On each move you can do the following, where input can be upper or lower-case:         1. Move into an adjacent room.  To move enter 'M' followed by a space and            then a room number.         2. Shoot your guided arrow through a list of up to three adjacent rooms, which            you specify.  Your arrow ends up in the final room.            To shoot enter 'S' followed by the number of rooms (1..3), and then the            list of the desired number (up to 3) of adjacent room numbers, separated            by spaces. If an arrow can't go a direction because there is no connecting            tunnel, it ricochets and moves to the lowest-numbered adjacent room and            continues doing this until it has traveled the designated number of rooms.            If the arrow hits the Wumpus, you win! If the arrow hits you, you lose. You            automatically pick up the arrow if you go through a room with the arrow in            it.         3. Enter 'R' to reset the person and hazard locations, useful for testing.         4. Enter 'C' to cheat and display current board positions.         5. Enter 'D' to display this set of instructions.         6. Enter 'P' to print the maze room layout.         7. Enter 'X' to exit the game.          Good luck!           You are in room 13. You smell a stench.          1. Enter your move (or 'D' for directions): P                ______18______               /      |       \              /      _9__      \             /      /    \      \            /      /      \      \           17     8        10     19           | \   / \      /  \   / |           |  \ /   \    /    \ /  |           |   7     1---2     11  |           |   |    /     \    |   |           |   6----5     3---12   |           |   |     \   /     |   |           |   \       4      /    |           |    \      |     /     |           \     15---14---13     /            \   /            \   /             \ /              \ /             16---------------20          You are in room 13. You smell a stench.          1. Enter your move (or 'D' for directions): m 12         You are in room 12.          2. Enter your move (or 'D' for directions): M 3         You are in room 3. You hear rustling of bat wings.          3. Enter your move (or 'D' for directions): c         Cheating! Game elements are in the following rooms:         Player Wumpus Bats1 Bats2 Pit1 Pit2 Arrow            3     14      4     7   18   16    -1          You are in room 3. You hear rustling of bat wings.          3. Enter your move (or 'D' for directions): r         (Remember arrow value of -1 means it is with the person.)         Enter the 7 room locations (1..20) for player, wumpus, bats1, bats2, pit1, pit2, and arrow:         3 14 4 2 18 16 2          You are in room 3. You hear rustling of bat wings.          3. Enter your move (or 'D' for directions): s         Sorry, you can't shoot an arrow you don't have.  Go find it.         You are in room 3. You hear rustling of bat wings.          4. Enter your move (or 'D' for directions): m 2         Woah... you're flying!         You've just been transported by bats to room 9         You are in room 9. You feel a draft.          5. Enter your move (or 'D' for directions): m 10         You are in room 10.          6. Enter your move (or 'D' for directions): m 2         Congratulations, you found the arrow and can once again shoot.         You are in room 2. You hear rustling of bat wings.          7. Enter your move (or 'D' for directions): s         Enter the number of rooms (1..3) into which you want to shoot, followed by the rooms themselves: 3 3 4 14         Wumpus has just been pierced by your deadly arrow!         Congratulations on your victory, you awesome hunter you.          Exiting Program ...

Implementation Details:

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. Use the starter code supplied in Codio, which provides you with some of the output you will need, such as functions to display the instructions and display the board.

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.

So that your output matches mine, I suggest you 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.

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

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

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:

Assessments

The 16 assessments cover all the various output messages and many of the game conditions.  Each assessment is worth between 2 to 6 points as follows:

      Points   Condition                                                            

Extra Credit 

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:

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, system("cls"); on Windows), 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 using the Codio Prog 5 Hunt the Wumpus Extra Credit  project.