Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Overview: For this homework you will be implanting a version of the game Wumpus. Wumpus is a text based adventure game. You are in a

image text in transcribedimage text in transcribedimage text in transcribedimage text in transcribedimage text in transcribedimage text in transcribedimage text in transcribedimage text in transcribedimage text in transcribedimage text in transcribedimage text in transcribedimage text in transcribedimage text in transcribedimage text in transcribedimage text in transcribedimage text in transcribedimage text in transcribedimage text in transcribedimage text in transcribed
Overview: For this homework you will be implanting a version of the game Wumpus. Wumpus is a text based adventure game. You are in a pitch black cave with 20 rooms. The rooms are arranged in a dodecahedron. IE each room has three exits to other rooms. Some of the rooms have a bottomless pit. Some of the rooms have a colony of super bats. Somewhere in the maze there is a sleeping Wumpus . Your job is to kill the Wumpus before it kills you, or you fall into a pit. ( Details below) You should provide a separate .h and .cpp les for each class you design, as well as a .cpp le with main() for running the program You will submit a single zip file containing all your files. I will compile your program by downloading your files and executing \"g++ *.cpp\" For testing run your program and test with various parameters to assure your program is following the parameters as set out. Additionally, we will look at your code for commenting / style provisions and as necessary for logic. One test we will run is to have a file of rooms to move to and redirect it to your application. For this to work you need to name your rooms as specied below. Game Details: Your will have 20 rooms, numbered 0 thru 19. They will be arranged as follows ( label room 20 as room 0) When you start the game, you will take three parameters on the command line. 0 NumBats o NumPits o WumpusTiredness If you do not provide three values, the program will remind you to enter values and exit. Something like incorrect number of parameters. Provide \"NumBots, NumPits, WumpusHeoith\" You will randomly populate the maze with the number of Bats specied. Bats are very territorial. Only one bat per room You will randomly populate the maze with the number of pits specified. No more than one pit per room. Note that a room with a pit may have a Bat. You will randomly populate the maze with a single Wumpus. The player will start in room 0. This implies that you cannot put a pit, bat, or Wumpus in room 0; If you enter a room with a bat, you will be picked up by the bat and carried to a new room. If you enter a room with a pit, you will fall into the pit and die { unless a bat picks you up and moves you to a new room) If you enter a room with a bat and a wumpus the bat will take you away before the Wumpus eats you. If you enter a room with a Wumpus - the wumpus will either move to a new room or eat you. The probability of eating or leaving is based on the Wumpus Tiredness. Whenever you enter a room ( either by moving there, or being carried by a bat) the program will give you some information about what you hear, feel, or smell. a If there is a Wumpus in an adjacent room you will be told \"You smell a Wumpus nearby\" I If there is a bat in an adjacent room you will be told \"You hear the wings of a bat fluttering\" I If there is a pit in an adjacent room you will be told \"You feel a cold draft\" You have two arrows. You can fire the arrow Into an adjacent room. If the Wumpus is in the room you kill it and win the game. If you try and fire your arrow into a non-adjacent room the arrow will break agains the wall. If you use up all of your arrows, you die and lose the game. If the Wumpus eats you , you die and lose the game. If you fall into a pit, you die and lose the game. To shoot an arrow you enter room #20 as the room you want to move to. The program will prompt you for the room number to fire into Bats: The giant bat hangs on the ceiling of the room Each bat starts off with one unit of health; Every turn the Bat gets another unit of health If you wander into a room with a bat, the bat will fly you to another room and drop you. The number of rooms the bat will travel is based on it's health. IE if 'BatHealth' is the health value you will be flown \"(BatHealth % 3j+1\" rooms. The room selection is at random . at each room you will randomly pick one of the three passageways out of the room When the bat drops you in the room, it's health will be reset to '1' and it will return to the original location. Pits: If you are dropped in a room with a bat, you will be picked up by that bat and flown to some other room. If you are dropped in a room with a pit, and no bat , you will die If you are dropped in a room with a Wumpus it will be as if you entered the room Enter a room with a pit and you die unless there is a bat to grab you and take you to another room Wumpus: The Wumpus is sleeping. When disturbed it will either eat you, or wander off to some other room , selected at random , and go back to sleep. TheVanpuscanhappygotoanyroonnthecave(suconfeetandtooheavyfora bat to move) The Wumpus has a tiredness factor that you set when you invoke the program. With each turn the tiredness factor is decremented by one. To determine if the Wumpus eats you you generate a random number from 0 to the tirednessFactor. If the generated number is '0' the Wumpus eats you. If the tirednessFactor is 0 the Wumpus always eats you. In order to test the program whenever the Wumpus moves to a new room ( and at the start of the game) print which room the wumpus is in. Sample Output: You are in room 11 You may go to room 10, Room 12r Room 19 Enter Choice :10 You are in room 13 You may go to room 2, Room 9, Room 11 Enter Choice :2 You are in room 2 You feel a draft You may go to room 1, Room 3, Room 18 Enter Choice :1 You are in room 1 You have fallen into a pit. You are dead You are in room 11 You may go to room 10, Room 12r Room 19 Enter Choice :10 You are in room 10 You may go to room 2, Room 9, Room 11 Enter Choice :2 You are in room 2 You hear the wings of a bat fluttering You smell a Wumpus nearby You may go to room 2, Room 9, Room 11 Enter Choice :9 You are in room 9 A giant bat picks you up and drops you in Room 13 You are in room 13 You have fallen into a pit. You are dead You are in room 2 You hear the wings of a bat fluttering You smell a Wumpus nearby You may go to room 1' Room 3, Room 19 Enter Choice :23 What direction do you want to shoot your arrow? Enter Room number :3 You have killed the Wumpus. You win. C++ Hints: There are a few tricky blts re C++ and this program Speclflcally 0 Getting Input from the command line and converting it Into numbers a Random number generation 0 How to handle map of rooms. IE what are the adjacent rooms. Getting input: The main {) function really has two additional arguments. The signature is: int (lulr To get the command line args. Do something like this thing rI.-1rm-".[I:-1 #include // Shows how to get a random number void showRandom() { srand( time (NULL) ) ; int r1 = rand() % 10 ; // Random number between 0 and 9 for ( int i = 0 ; i 19) return false; if ( rooms [MAPPING [ roomNumber ] [0] ] . haspit()) return true; if rooms [MAPPING [ roomNumber ] [1] ] . haspit()) return true; if ( rooms [MAPPING [ roomNumber ] [2] ] . haspit()) return true; return false;Driver class #include "map-h" class Driver { . Why all these private methods? public: Driver (int numBats, int numPits, int wumpusHealth) ; . Breaks up the logic into smaller void playGame () ; more comprehensible pieces private: Map map; . Makes reading the playGame() int currentRoom; easier. int numArrows ; bool _isAlive; bool isAtRisk( int currentRoom) ; bool dealwithIssues ( Room &); void speakWarning( int ) const ; bool shootArrow() ;\f\fplayGame() cout > nextRoom; // Deal with next rom choice.[ if ( nextRoom == 20) { // Shoot arrow return true if game over if ( shootArrow()) return; else if ( nextRoom == -1) { return; else if ( ! map. isAccessable( currentRoom, nextRoom) ) { cout

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Financial management theory and practice

Authors: Eugene F. Brigham and Michael C. Ehrhardt

12th Edition

978-0030243998, 30243998, 324422695, 978-0324422696

Students also viewed these Programming questions