Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

PleaseChegg Solver, This is my 4th Same question trying to get an answer, But ea

ID: 3887570 • Letter: P

Question

PleaseChegg Solver, This is my 4th Same question trying to get an answer, But earlier guys just copy and paste the code from diff sites which is not working.

So please just answer if you know how to solve it, do not waste my question. Please read the question and be sure to use all the method and run the code, please use C++ language, do it from scratch and do in a basic way. it should just print one maze and run the robot and also pausing for 1 seconds,

If you want to be clear with any requirement comment first and answer it later, because I have wasted so many question for this one. Thanks.

– Robot in Maze
Hand in hard copy of your code. Be prepared to run your code in the class.
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:
**********
*
** *** * *
** *******
* X **
******* **
*** *** **
*
**********
**********

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 maze[][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.

And
Make your robot ‘smarter’, so that it escapes the maze faster. For example, you can give your
robot a memory.

Explanation / Answer

main.cpp

#include <iostream>
#include <vector>
#include <string>
using namespace std;

enum { FIN = '*', SPACES = ' ', DEEWAR = '#', TRY = '!', USES = '+' };

class maze_traversal {
std::vector<std::string> dat;
public:
char &operator()(size_t a, size_t b) {
return dat[b][a];
}

friend std::istream &operator>>(std::istream &so, maze_traversal &er) {
std::string tempo;
while (std::getline(so, tempo))
er.dat.push_back(tempo);
return so;
}

friend std::ostream &operator<<(std::ostream &os, maze_traversal const &er) {
for (auto const &s : er.dat)
os << s << ' ';
return os;
}

size_t y_dim() { return dat.size(); }
size_t x_dim() { return dat[0].size(); }
};

bool solving(maze_traversal &er, size_t a = 0, size_t b=0) {
if (a < 0 || b < 0 || a >= er.x_dim() || b >= er.y_dim())
return false;

if (er(a, b) == FIN)
return true;

if (er(a, b) != SPACES)
return false;

er(a, b) = USES;

bool performed
= solving(er, a - 1, b)
|| solving(er, a + 1, b)
|| solving(er, a, b - 1)
|| solving(er, a, b + 1);

if (!performed)
er(a, b) = TRY;

return performed;
}

int main(){
maze_traversal er;
std::cin >> er;

solving(er);
std::cout << er;   
}

Rate an upvote.....Thankyou

Hope this helps.......