One of the first computer games in the 1970's was an adventure game called "Hunt the Wumpus." For this assignment, you will implement a slightly less violent version of this map-based game. In this version, you explore a maze of caves, hunting the dreaded wumpus (or possible more than one wumpi). When you enter a cave that is adjacent to a wumpus, you will smell its stench. Warned by your nose, you can then throw a stun grenade into an adjacent cave to try to knock out and capture the wumpus. Unfortunately, the sound of the explosion will alert any nearby wumpi and set them in motion. The object of the game is to capture all of the wumpi before you run out of grenades (and without getting mauled). In addition to wumpi, there is a bottomless pit and giant bats to avoid. Below is a sample execution of the game.
You have been given the following classes to represent the maze structure and implement the logic of the game: CaveMaze.java, CaveContents.java, and caves.txt. In addition, the javadoc page for Cave.java is provided.
In addition, you have been given two different interface clases: WumpusTerminal.java is a simple, terminal based interface, while WumpusGUI.java is a graphical user interface that uses buttons and a text area. Your modified classes should work with either of these interfaces.
You are to implement the Cave class, which models a single cave in the maze. Each cave has a name and a number associated with it, and is connected to three other caves through tunnels. By default, a cave is empty (using the enumerated type value CaveContents.EMPTY) but it can be assigned to contain a wumpus (CaveContents.WUMPUS), a swarm of bats (CaveContents.BATS), or a bottomless pit (CaveContents.PIT). In addition, a cave is initially unvisited, but it can be marked as visited. The getName
method should return the name of the class if it has been visited, otherwise "unknown".
Be sure to test your Cave class thoroughly.
An incomplete implementation of the CaveMaze class is provided. Currently, it reads in the cave data file (caves.txt) and allows the player to move around the maze. You are to complete the functionality of the game by making the following additions.
showLocation
method so that a warning is returned if the player is adjacent to a cave containing a wumpus ("You smell an awful stench coming from somewhere nearby."), the bottomless pit ("You feel a draft coming from one of the tunnels."), or bats ("You hear the flapping of wings close by."). Note that it is possible that more than one warning might be included in the returned message depending on the contents of the adjacent caves. However, the same message should never appear more than once (e.g., even if there are multiple wumpi nearby). Also, the order of the warnings should not be a clue as to the cave contents.
move
method so that moving into a nonempty cave has consequences. If the cave contains a wumpus or the bottomless pit, the player is disabled (with an appropriate message returned). If the cave contains the bats, then the player is picked up and dropped off in a random empty cave in the maze (with an appropriate message returned).
toss
method so that it tosses a stun grenade (assuming the player has any remaining) into the specified tunnel. If that tunnel contains a wumpus, then it is stunned and captured. However, any wumpi adjacent to the player are alerted by the sound of the explosion and move at random. That is, each adjacent (surviving) wumpus picks a tunnel at random. If the cave along that tunnel is empty, then the wumpus moves there. If that happens to be the cave where the player is, then he/she is mauled and disabled. Note that if the cave selected for movement is not empty, then the alerted wumpus does not move.
For extra credit, be creative and add additional features to the game. You may also change the scenario if you wish, but be sure to keep the basic functionality described here.