Reference no: EM131288395
This project will require knowledge of the following programming techniques:
- Reading, understanding, and modifying existing code.
- Control Structures.
- Arrays and multi-dimensional arrays.
- Debugging, testing, and code maintenance techniques.
- Building a large, complex program with several parts.
Task 0: Read and Understand the Code
Thoroughly read through the existing code and documentation. Compile it. Run it. Move the player through the rooms. Become familiar with the design and methods. Answer the following questions completely in a separate Word document and submit those answers with your project.
1. Consider the static variables declared on lines 11-15:
a) What kind of variables they (not the data type, but the kind based on their location in the code)?
b) Why are those variables declared inside the class instead of inside a method?
2. In your own words, explain the design of the adjacentRooms rectangular array. What does the array represent?
3. Conceptually what does adjacentRooms.GetLength(0) represent? Be specific within the context of Hunt The Wumpus.
4. Conceptually what does adjacentRooms.GetLength(1) represent? Be specific within the context of Hunt The Wumpus.
5. Look at the loop condition for running the game (inside Main()). When will the game end?
6. Currently there are ten (10) methods besides Main(). List each method header and briefly describe what that method does.
Task 1: Shoot the Wumpus
Our player is unarmed and cannot defeat the Wumpus. Arm the player with arrows that he can shoot at the Wumpus. The arrows can be shot into any adjacent room. Write code that does the following:
1. Implement the ‘shoot' command. If the player types ‘shoot' the program should ask ‘Which Room?' The player can then type in an adjacent room number to shoot into that room.
- Detect if the player types in an invalid room and print out "You cannot shoot there."
- [Hint] Look at the code for the ‘move' command. How different is shoot from move?
- Run the program. Verify that you handled invalid rooms correctly.
2. Once the player shoots the arrow into a room:
- If the room HAS the Wumpus:
i. Print out "ARGH...Splat!"
ii. Print out "Congratulations. You killed the Wumpus! You Win." The game ends.
- If the room does not have the Wumpus:
i. Print out "Miss! But you startled the Wumpus".
ii. Shooting the arrow startles the Wumpus and it moves to another room. Move the Wumpus to any random room including the room you are currently in -- in which case the player will die. Create a separate method to move the startled wumpus.
iii. Print out a trace message that tells you which room the Wumpus moved to.
3. Run the program. Test both missing the Wumpus and hitting it.
Task 2: Add Bats
The Wumpus isn't the only creature that calls these caves home. There are other hazards. Superbats are large and scary bats that when startled pick you up and fly you to a random room. Implement the following to add superbats to the game:
1. Place bats in TWO random rooms at the start. Bats cannot be in room 0, the same room as the Wumpus, or the same room as other bats.
2. Print out trace messages that tell you which rooms the bats are in.
3. If you enter a room adjacent to the bats, you can hear them and you should print out "Bats nearby!" Implement this feature. Look at InspectCurrentRoom()to see how it is implemented for the Wumpus. Your code will be very similar to that.
4. Run the program. Test that you can detect the bats in an adjacent room.
5. If you enter a room with the bats, the bats fly you away to any random room. Look at InspectCurrentRoom(). That is where you will write the code to identify if you entered a room with bats. How can you add logic that will then move the player to another random room?
- The game should display "Snatched by superbats!" when bats move you to a new room.
- The new room might contain the Wumpus, a bottomless pit, or even other bats and you have to handle that. The bats moving you should work just like a normal move.
6. Run the program. Test that the bats will fly you to another room.
Task 3: Add Bottomless Pits
Another hazard in these caves is the bottomless pit. If you enter a room with a bottomless pit you will fall to your death. Add bottomless pits to your game:
1. Place bottomless pits in TWO random rooms at the start. A bottomless pit can be in any room except room 0.
- If a bottomless pit and bats are in the same room, the bats will fly you to safety.
- The Wumpus has sucker feet and won't fall into the bottomless pit if they are in the same room.
2. Print out trace messages that tell you which rooms have the bottomless pits.
3. If the player enters a room with a bottomless pit, the player will die and the game will end.
- The game should display "YYYIIIIEEEE...fell in a pit."
4. Run the program. Go into a room with a bottomless pit and verify that it works.
5. If you enter a room adjacent to a bottomless pit you feel a draft and should print out "You feel a draft..." Implement this feature. It will be very similar to your implementation for the bats.
6. Run the program. Test that bottomless pits work as described.
Task 4: Implement the ‘quit' command
We want to allow the player to quit mid-way through a game. Implement the ‘quit' command. If the player types ‘quit' the game should end and return to the main menu.
Task 5: Play again?
If the player dies from the Wumpus or falls into a pit, they may want to replay the same exact map again. Implement code that does that.
1. Once the game is over, prompt the user if they would like to replay the same map again.
2. If the player says yes, start a new game but on the exact same map with the Wumpus, bats, and bottomless pits all in the same places.
3. If the player says no, the game should end and return to the main menu.
Task 6: Keeping Score
Let's start to keep score now. Come up with your own scoring rules and implement them. Once the game ends, tell the player their score. What object should keep track of the player's score?
Some possible scoring rules:
- The player should get points for killing the Wumpus.
- The player should lose points for getting eaten or falling into a bottomless pit.
- Maybe the player should get more points for killing the Wumpus quickly (less moves).
- Maybe the player should lose points for shooting but missing the Wumpus.
Task 7: Save the Score to Disk
Use the File I/O techniques we just learned to save the player's high score to a file called
WumpusHighScore.txt on the Hard Drive.
1. After you display the high score to the player, save it to the disk.
2. You should append to the existing file so all previous high scores remain.
3. Run the program. Test that the high score is successfully written to disk. Test that multiple high scores will correctly append to the file.
Task 8: Implement ViewHighScores()
Implement the ViewHighScores() method to load the high score file from disk and display them one high score per line.
Task 9: Add Treasure
Add a treasure to the game. Place a gold bar somewhere in the cave. If the player finds it, they get extra points. Notify the player that they found bar.
Task 10: Add a New Type of Cave
Our cave layout is a dodecahedron. It is static and the layout will never change. Implement one other type of cave that is a different layout. When the game starts, ask the player which cave layout they would like to use and build that type of cave network.
Consider the design of the adjacentRooms rectangular array and how you can initialize it to different values based on user input.
Some possible cave layouts are listed at the end of this document. Each number represents the room id starting at room 0. You can also make your own design.
Finishing Up Tasks
1. Remove all trace or debugging messages you wrote. This should make the game much more challenging and fun now -- ready for prime time.
2. Implement the PrintInstructions() method. Just display a few instructions to get a new player started in the game.