Question: Robot in Maze How do I use a Random Number generator to make the robot move randomly inside the array? This is my code so

Robot in Maze

How do I use a Random Number generator to make the robot move randomly inside the array?

This is my code so far:

#include

#include

using namespace std;

void showMaze(char maze[][10], int columns, int rows, int xLoc, int yLoc);

void robot(char maze[][10], int lastColumn, int lastRow, int &nextColumn, int

&nextRow);

int main()

{

char maze[10][10] =

{ { '*', ' ', '*', '*', '*', '*', '*', '*', '*', '*' },

{ '*', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '*' },

{ '*', '*', '*', '*', ' ', '*', '*', '*', '*', '*' },

{ '*', '*', ' ', '*', ' ', '*', '*', '*', '*', '*' },

{ '*', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '*', '*' },

{ '*', '*', '*', '*', '*', '*', '*', ' ', '*', '*' },

{ '*', '*', '*', ' ', '*', '*', '*', ' ', '*', '*' },

{ '*', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ' },

{ '*', '*', '*', '*', '*', '*', '*', '*', '*', '*' },

{ '*', '*', '*', '*', '*', '*', '*', '*', '*', '*' } };

showMaze(maze, 10, 10, 0, 1);

system("pause");

return 0;

}

void showMaze(char maze[][10], int columns, int rows, int xLoc, int yLoc)

{

for (rows = 0; rows

{

for (columns = 0; columns

if ((rows == xLoc) && (columns == yLoc))

cout

else

cout

cout

}

}

Robot in Maze How do I use a Random Number generator to

Homework 2-Robot in Maze Hand in hard copy of your code. Be prepared to run your code in class. Begin this homework with your code for Homework 1 Create a robot that moves through the maze. The robot makes random moves up, down, left, and right. It can only 'see' locations that are directly adjacent to its current location. After each move, display the robot as an 'X in the maze, and press 'enter to make the next move Here is an example display. The entrance is on the upper left and the exit is on the lower right 844 + t5 84444 Count the number of moves and, if the robot escapes the maze, display the total Your program should have three functions: createMaze(char maze[[columns], int columns, int rows)-initializes your maze showMaze(char mazel)[columns], int columns, int rows) display maze and robot robot(char maze[columns], int lastColumn, int lastRow, int &nextColumn, int &nextRow)-robot makes a random move Be sure to pass maze and robot position as parameters in the function call- do no use global variables

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!