Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

5. Deliverables & Tips The objective of this project is to test the skill of the student in problem solving using the C++ programming language

image text in transcribedimage text in transcribedimage text in transcribedimage text in transcribedimage text in transcribedimage text in transcribedimage text in transcribed

5. Deliverables & Tips The objective of this project is to test the skill of the student in problem solving using the C++ programming language The student is to create a small game that simulates the control of the Mars Rover. Sample sessions of an actual such basic program is provided for your reference in the Figure in the next section of this document, Take note that the program generates everything on the display. Those parts that required user's response (after the ">" symbol) are to be typed by the user. Take note that this is only the minimal basic requirement: you should add as much features as possible to your program and to make it as user-friendly as possible in order to get better marks Recommendation on how to develop the program: a. Create a class named Map which would be used to create the following: The actual Map of Mars, which is to be hidden from the user and will only be displayed to the user at the end of the game. The Mars Rover Mapper, which keeps track of the cells in the map the Rover had already observed. b. Olle possible minimal class declaration for Map is shown below: class Map private: vector > map: int dix, dimY; public: Map (int dimx, int dimy); void resize(int dimx, int dimy, char ch); void display(); void setObject(int x, int y, char ch), char getobject(int x, int y) bool isEmpty(int x, int y); bool is ill(int x, int y); bool isTrap (int x, int y); bool isInsideYap (int n, int y); int getDimx(); int getDimy(); ); //Map C. Create a class named Rover, which would be insed to keep track of the location and heading of the Rover. One possible minimal class declaration is shown below. class Rover privale: int x, V; Direction heading: char object Undor Rover: Map' p_mars; //a pointer to the map for Mars Map mapper; la map that keeps track of observed cells so far public: ROTOT() void land (Maps mars); //links a map of Mars to a Rover hool turnleft(); bool turnright(); bool move(); void displayMapper) bool executeCommand(char command); 1 //Have: d. The class declarations above are only the bare minimal, you may want to add member functions and data member such as for keeping track of golds collected etc e The data type Direction can be defined using enumeration as shown below. Please refer to your textbook on how to use enum.. onum Direction north = 0, south - 2 f As the Rover moves across the map front of it would be able to read the three cells just in 4. There are hills on the map which prevent the Rover from moving to those cells. h. There are traps on the map, if the Rover moves to any of those cells, the mission is failed i. You are free to design your scoring system and other type of cells, you may also introduce new challenges for the Rover. The Mars Rover assumed to be ALWAYS starts at the centre of the map which is ALWAYS an empty space, but the Rover's heading can start at any of the north, east, south or west direction You MUST design your map such that all the golds are reachable from the starting cell and that they can be collected by the Rover The ALGORITHM TO GENERATE THE MAP would constitute AT LEAST ONE- TIIIRD OF TIIE TOTAL MARKS of the assignment, all the cells must be randomly generated with good schemes, FOCUS FIRST on designing the algorithm that generates the map. Use your creativity!! Yes, programming is also a CREATIVE PROCESS A possible approach to generate the map is as follows: Step 1: Populate the cells in the map with objects (i.e. represented using characters) using a desired probability. Step 2: Change the cell at the centre of the map to be an empty space (since the Rover is always assumed to start at the centre). Step 3: Do a partially random walk in the map starting at the centre of the map, with a random heading direction Step 4: Keep moving in the current direction and change the cells to be empty spaces as we move along that direction. Step 5: Generate a pscudo-random number, and based on that number, decide whether to turn left, turn right, or contime in the same direction. For example, in order to have a 20% chance of turning left, 20% chance of turning right, and 60% chance of moving ahead, you can generate a pseudo-random number in the range from 0 to 9 and tuin left if the number turns out to be 0 or 1. tum right if the number turns out to be 8 or 9, and stay in the same direction otherwise. If you reach the boundary of the map, just turn around Step 6: As you move along the map. generate a pseudo-random number, and decide to put a gold object or not. For example, generate a pseudo-random number in the range from 0 to 9. if the number is 0. you change the object at the cell to be a gold object, this means there is a 10% chance of dropping a gold when you move along the map. Step 7: Repeat Step 4 onwards until you have dropped desired munber of golds. Sample Session of a Demo Program is shown Let's explora MATE M. dinion X =1 Mars dimension T-5 Nu of Gold => 4 --_--_Mere Rover Mapper LIT S???? 41771 2121212121 11??? +-+-+-+-+-+- 111111 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 Mision: Get all the goldall, Do not get trapped!! L-Turn Left, E-Turn Right, M-Hove, C-Quit 111 H-Trap --Gold Total Command Serence - U ts] Total Commands - O [C] Total de Glot of 4 Total Score - [C] x 50 - [9] x 5 - [C] x 1-0 Example samance: MMMMMMMMMTIL Enter cod weyuncu -> MLMLLM 5. Deliverables & Tips The objective of this project is to test the skill of the student in problem solving using the C++ programming language The student is to create a small game that simulates the control of the Mars Rover. Sample sessions of an actual such basic program is provided for your reference in the Figure in the next section of this document, Take note that the program generates everything on the display. Those parts that required user's response (after the ">" symbol) are to be typed by the user. Take note that this is only the minimal basic requirement: you should add as much features as possible to your program and to make it as user-friendly as possible in order to get better marks Recommendation on how to develop the program: a. Create a class named Map which would be used to create the following: The actual Map of Mars, which is to be hidden from the user and will only be displayed to the user at the end of the game. The Mars Rover Mapper, which keeps track of the cells in the map the Rover had already observed. b. Olle possible minimal class declaration for Map is shown below: class Map private: vector > map: int dix, dimY; public: Map (int dimx, int dimy); void resize(int dimx, int dimy, char ch); void display(); void setObject(int x, int y, char ch), char getobject(int x, int y) bool isEmpty(int x, int y); bool is ill(int x, int y); bool isTrap (int x, int y); bool isInsideYap (int n, int y); int getDimx(); int getDimy(); ); //Map C. Create a class named Rover, which would be insed to keep track of the location and heading of the Rover. One possible minimal class declaration is shown below. class Rover privale: int x, V; Direction heading: char object Undor Rover: Map' p_mars; //a pointer to the map for Mars Map mapper; la map that keeps track of observed cells so far public: ROTOT() void land (Maps mars); //links a map of Mars to a Rover hool turnleft(); bool turnright(); bool move(); void displayMapper) bool executeCommand(char command); 1 //Have: d. The class declarations above are only the bare minimal, you may want to add member functions and data member such as for keeping track of golds collected etc e The data type Direction can be defined using enumeration as shown below. Please refer to your textbook on how to use enum.. onum Direction north = 0, south - 2 f As the Rover moves across the map front of it would be able to read the three cells just in 4. There are hills on the map which prevent the Rover from moving to those cells. h. There are traps on the map, if the Rover moves to any of those cells, the mission is failed i. You are free to design your scoring system and other type of cells, you may also introduce new challenges for the Rover. The Mars Rover assumed to be ALWAYS starts at the centre of the map which is ALWAYS an empty space, but the Rover's heading can start at any of the north, east, south or west direction You MUST design your map such that all the golds are reachable from the starting cell and that they can be collected by the Rover The ALGORITHM TO GENERATE THE MAP would constitute AT LEAST ONE- TIIIRD OF TIIE TOTAL MARKS of the assignment, all the cells must be randomly generated with good schemes, FOCUS FIRST on designing the algorithm that generates the map. Use your creativity!! Yes, programming is also a CREATIVE PROCESS A possible approach to generate the map is as follows: Step 1: Populate the cells in the map with objects (i.e. represented using characters) using a desired probability. Step 2: Change the cell at the centre of the map to be an empty space (since the Rover is always assumed to start at the centre). Step 3: Do a partially random walk in the map starting at the centre of the map, with a random heading direction Step 4: Keep moving in the current direction and change the cells to be empty spaces as we move along that direction. Step 5: Generate a pscudo-random number, and based on that number, decide whether to turn left, turn right, or contime in the same direction. For example, in order to have a 20% chance of turning left, 20% chance of turning right, and 60% chance of moving ahead, you can generate a pseudo-random number in the range from 0 to 9 and tuin left if the number turns out to be 0 or 1. tum right if the number turns out to be 8 or 9, and stay in the same direction otherwise. If you reach the boundary of the map, just turn around Step 6: As you move along the map. generate a pseudo-random number, and decide to put a gold object or not. For example, generate a pseudo-random number in the range from 0 to 9. if the number is 0. you change the object at the cell to be a gold object, this means there is a 10% chance of dropping a gold when you move along the map. Step 7: Repeat Step 4 onwards until you have dropped desired munber of golds. Sample Session of a Demo Program is shown Let's explora MATE M. dinion X =1 Mars dimension T-5 Nu of Gold => 4 --_--_Mere Rover Mapper LIT S???? 41771 2121212121 11??? +-+-+-+-+-+- 111111 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 Mision: Get all the goldall, Do not get trapped!! L-Turn Left, E-Turn Right, M-Hove, C-Quit 111 H-Trap --Gold Total Command Serence - U ts] Total Commands - O [C] Total de Glot of 4 Total Score - [C] x 50 - [9] x 5 - [C] x 1-0 Example samance: MMMMMMMMMTIL Enter cod weyuncu -> MLMLLM

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_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

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

Get Started

Students also viewed these Databases questions

Question

1. Are my sources credible?

Answered: 1 week ago

Question

3. Are my sources accurate?

Answered: 1 week ago

Question

1. Is it a topic you are interested in and know something about?

Answered: 1 week ago