Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Playing the game should look like the following: Author: Dale Reed Program 4: RicoRobots in C++ TA: Billie Joe Armstrong, T 6:00 AM March 22,

Playing the game should look like the following:

Author: Dale Reed Program 4: RicoRobots in C++ TA: Billie Joe Armstrong, T 6:00 AM March 22, 2018 Welcome to Ricochet Robots ('Ricochet Robot' is a registered trademark of Hans im Glck Munich, Germany, 1999. The game was created by Alex Randolph.) The object of the game is to get the designated numbered robot to the indicated letter position. The numbered squares are all robots. They unfortunately have no brakes, and so will continue in whatever direction they are moving until they encountar an obstacle. For each move enter the robot number and the desired direction. For instance entering 1 U would move the #1 robot up as far as it can go. The first letter of input is the robot number (1 - 4), and the second letter is the direction: (L=left, U=up, R=right, D=down) Enter x to exit. Have fun! Enter 'r' for random robot and goal, 'd' for default or 's' to select: d Move robot 2 to square M ---------------------------------------------------------------- | . . . . . | . . . . . . | . . . . . | | | | . . . | . . . . . . | . . . . . . . | | --- --- --- | | . . . . . . . . . . . . . . . | . | | | | . | . . . . . . . . . . . . . . . | | --- --- | | . . . . . . | . . . . . | . . . . . | |--- --- --- | | . . . . . . . . . . . . . . . 4 | | --- --- | | . . . . . . | . . . . . . | . . . . | | --- --- | | . . . . | . . . | . . | . . . . . . . | | --- | | . . . . . . . | . . | . . . . . . . | | --- --- --- --- | | . . | . . . | . . . . . . . . . . . | | --- | | . . . . . . . . . | . . . . . . . | |--- --- --- | | . . . . . . . . . . . . . | 3 . . | | | | . . . . . . M | . . . . . . . . . | | --- | | . . . . . . . . . | . . . . . . . | | --- --- | | . . | . . . . . . . . . . . . 1 | . | | --- | | . . . . . . | . . . . . . | . . . 2 | ---------------------------------------------------------------- 1. Please enter the robot to move and the direction (e.g. 2 r): 2u Move robot 2 to square M ---------------------------------------------------------------- | . . . . . | . . . . . . | . . . . . | | | | . . . | . . . . . . | . . . . . . . | | --- --- --- | | . . . . . . . . . . . . . . . | . | | | | . | . . . . . . . . . . . . . . . | | --- --- | | . . . . . . | . . . . . | . . . . . | |--- --- --- | | . . . . . . . . . . . . . . . 4 | | --- --- | | . . . . . . | . . . . . . | . . . . | | --- --- | | . . . . | . . . | . . | . . . . . . . | | --- | | . . . . . . . | . . | . . . . . . . | | --- --- --- --- | | . . | . . . | . . . . . . . . . . . | | --- | | . . . . . . . . . | . . . . . . 2 | |--- --- --- | | . . . . . . . . . . . . . | 3 . . | | | | . . . . . . M | . . . . . . . . . | | --- | | . . . . . . . . . | . . . . . . . | | --- --- | | . . | . . . . . . . . . . . . 1 | . | | --- | | . . . . . . | . . . . . . | . . . . | ---------------------------------------------------------------- 2. Please enter the robot to move and the direction (e.g. 2 r):

Notes

I have created a sample program to get you started. It reads in the datafile and displays the board, and moves the robot #2 upwards one square. Pay careful attention to how the board is stored. Both the board display characters and the walls are stored in the same 2-dimensional array, with constants used as indexes to references the different aspects of each square. See also this pictoral description of the board representation.

For full credit (10 points of the programming style Data and Control Structures category) you will need to transform the above sample code into a version that uses C++ classes.

When selecting 'd' for the default game values, the default values should be selected to move robot 2 to square M. Selecting 'r' should give different values each time the program is run. Choosing 's' allows specifying the values to be used, and should first display the board with all the possible letter destination squares and robot positions shown, such as:

 ---------------------------------------------------------------- | . . . . . | . . . . . . | . . . . . | | | | . . A | . . . . . . | B . . . . . . | | --- --- --- | | . . . . . . . . . . . . . . C | . | | | | . | D . . . . . . . . . . . . . . | | --- --- | | . . . . . . | E . . . F | . . . . . | |--- --- --- | | . . . . . . . . . . . . . . . 4 | | --- --- | | . . . . . G | . . . . . . | H . . . | | --- --- | | . . . I | . . . | . . | . . . . . . . | | --- | | . . . . . . . | . . | . . . . . . . | | --- --- --- --- | | . J | . . . | K . . . . . . . . . . | | --- | | . . . . . . . . L | . . . . . . . | |--- --- --- | | . . . . . . . . . . . . . | 3 . . | | | | . . . . . . M | . . . . . . . . . | | --- | | . . . . . . . . . | N . . . . . . | | --- --- | | . . | O . . . . . . . . . . . 1 | . | | --- | | . . . . . . | . . . . . . | . . . 2 | ---------------------------------------------------------------- 

There is no real animation in this program. After the user enters a move, the screen is erased using system("cls") on windows or system("clear") on Mac or Linix, or simply displaying the new screen which causes the old one to scroll off the top. (Once done with everything else in the program, see here for an automatic way to check which system you are on, but you don't need to do this.)

Datafile format: The datafile must be called board.txt The top three lines of the datafile are comments. The two lines after that describe the number of possible destination squares (15 in the below example). The second line describes the number of "special" squares on the board, that is squares that have some combination of walls and display label (29 in the below example). Note that the side squares don't count for this as "special", as they are handled separately. After the first five lines, most of the entries give the piece index (reflecting its position on the board), a set of "wall" and 0 characters denoting what is present in each of the piece's four adjacent directions, and an optional alphabetic capital letter to be displayed in that position. The four characters after each piece board position (going from left to right) represent first the left wall, then the top, then the right, then the bottom wall, if any. For example the entry:

18 00|- A describes the board at square 18, that has nothing to the left (0), nothing above (0), a wall to the right (|), and a line below (-). Your program must work for any valid data file. We will test your program with a different data file than the one shown below.

# Datafile for RicoRobots program. Top numeric line is the number of special letter characters. # Second numeric line is number of special display characters define below. # The last set of lines define the placement of the numbered robots. 15 29 5 |000 11 |000 18 00|- A 25 |00- B 46 0-|0 C 49 |00- D 64 |00- 70 |-00 E 74 00|- F 95 0-|0 101 0-|0 G 108 |-00 H 115 00|- I 119 |-00 120 0-|0 135 |00- 136 00|- 145 0-|0 J 149 |-00 K 159 00|- 160 |00- 168 00|- L 189 |-00 198 00|- M 217 |00- N 226 |00- O 238 0-|0 246 |00- 252 |00- 238 red 255 green 189 blue 95 yellow 

The last four lines are the four robot positions, with robot 1 at position 238, robot 2 at 255, robot 3 at 189, and robot 4 at 95. You can ignore the color information on each line. (The color names are only used if you are implementing the extra credit.)

c++ only please, and ensure code complies and run.

link to sample code: https://sites.google.com/site/uiccs141/programs/prog-5-ricorobots/prog5Sample.cpp?attredirects=0?

link to data file:https://sites.google.com/site/uiccs141/programs/prog-5-ricorobots/board.txt?attredirects=0?

Comment if i'm missing any more details

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access with AI-Powered 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

Students also viewed these Databases questions

Question

What are the different techniques used in decision making?

Answered: 1 week ago