BEST代写-线上编程学术专家

Best代写-最专业靠谱代写IT | CS | 留学生作业 | 编程代写Java | Python |C/C++ | PHP | Matlab | Assignment Project Homework代写

C++代写 | CptS 122 Assignment 4: Hunt the Wumpus Game

C++代写 | CptS 122 Assignment 4: Hunt the Wumpus Game

这次的任务是用C++开发一个名为“Hunt the Wumpus Game”的小游戏

CptS 122- Data Structures
Programming Assignment 4: Hunt the Wumpus Game
The game is played on a 5×5 grid. The grid contains a player (you), a wumpus (the enemy!), a
pot of gold (reward) and some pits (random number from 5 – 10). Moving over a pit or onto a
wumpus loses the game. Moving over the gold wins you the game.
The state of the game should be stored in a class called GameWorld. A private field of that class
should be a 2-dimensional array of size 5. This array should store the state of the game. As this is
a class, you should have at least the following public members:
• GameWorld(…) // constructor that creates the game with a random startup
• displayEntireWorld(…) // This should display the game state to the screen
• displayVisibleWorld(…) // Displays all squares one away from the player
• moveUp(…) // Move the player up one square
• moveDown(…) // Move the player down one square
• moveRight(…) // Move the player right one square
• moveLeft(…) // Move the player left one square
• haveIWon() // returns true or false if the player has won
• amIAlive() // returns true or false depending on if player hit a Wumpus or pit
IV. Tasks
Your code should allow the player to, starting from a random location, explore the game world.
Start by creating an object of GameWorld in main (which should call the constructor which sets
up a random instance of the world. Then display the visible world and display a menu letting the
user make some moves.
This menu should take the following input:
• i or I should move the player up
• k or K should move the player down
• j or J should move the player to the left
• l or L should move the player to the right
• v or V should use the displayVisibleWorld show what is in the caves adjacent to
the player
• c or C should cheat and show the entire state of the game using
displayEntireWorld function
• r or R should restart the game with the same player
• n or N should restart the game with a new player
• q or Q should end the game
After implementing the appropriate action, your code should check to see if it is over a wumpus
or a pit, or if it has won by getting the gold. Display the results. You should then loop over this
code until either the player finds the gold or dies. You should also display appropriate error
messages if the player tries to move in an invalid direction (tries to leave the board) or uses an
invalid input.
Points Awarded:
• For every move the Player stays alive: 5 points
• For every time the Player uses displayVisibleWorld: – 2 points
• For every time the Player displayEntireWorld: – 5 points
Points should be tabulated and then saved in a file called “GameScores.txt” with Player’s
Name and corresponding points. (You must utilize an overloading operator
V. Console Output Example:
• W = Wumpus
• P = Pitt
• U = Player/User
• G = Gold
P
P U P
W G
P P
Figure 2—displayEntireWorld( ) Function Call
P
U
W
Figure 3 – DisplayVisibleWorld( ) Function Call
VI. Submitting Assignment:
1. Must submit your assignment in a zip file through blackboard.
2. Your project must contain at least one header files (.h files) and two C++ source files (which
must be .cpp files). There should be one .h file per class declaration. There should be one
.cpp for each set of operations belonging to a single class and one for the main () function.

bestdaixie

评论已关闭。