Question: Hi, Could you please help me to solve the question. Also, could you please answer questions in clear hand-writing and show me the full process,

Hi, Could you please help me to solve the question. Also, could you please answer questions in clear hand-writing and show me the full process, thank you. I need to write the program in C++

8.16 (Maze Traversal) The grid of hashes(#)and dots(.) is a two-dimensional array representation of amaze. In the two-dimensional array, the ashes represent the walls of the maze and the dots represent squares in the possible paths through the maze. Moves can be made only to a location in the array that contains dot. There is a simple algorithm for walking through a maze that guarantees finding the exit (assuming that there is an exit). If there is not an exit, youll arrive at the starting location again. Place your right hand on the wall to your right and begin walking forward. Never remove your hand from the wall. If the maze turns to the right, you follow the wall to the right. As long as you do not remove your hand from the wall, eventually, youll arrive at the exit of the maze. There may be a shorter path than the one youve taken, but you are guaranteed to get out of the maze if you follow the algorithm.

Do not solve this project with recursion. Instead, follow the right-hand rule as described in the text and below.

Do not interactively enter the maze. There are 3 h files below that you can download and include into your source using an #include. Only do one at a time. Do not include all three h files in the source at the same time. An include statement example is given. Put the include where you would have declared your matrix.

#include "mazelayout1.h"

Program a rat (your maze runner) to have a direction: up, right, down, and left (can be coded 0,1,2,3), as its forward direction. Based on which of the four directions, it should then try to go right relative to its forward direction. E.g. if facing up then step right, if facing right then step down, facing down then left, etc. But in the case of facing up, if you can't go right, then try to go forward. If not, try going left, otherwise step backward (which you can always do). If you successfully take a step in that direction, change the direction for the next iteration. You may backtrack, of course, as you never become blocked. As you step forward, change the . to *; if you backtrack, then change the * to -. Of course, don't go through a wall #. Print the matrix/maze at each step. Stop when the rat finds the exit.

FIRST MAZE LAYOUT

//Establish fixed maze '#' is a wall, '.' is a path

char maze[12][12] = {

{ '#', '#', '#', '#', '#', '#', '#', '#', '#', '#', '#', '#' },

{ '#', '.', '.', '.', '#', '.', '.', '.', '.', '.', '.', '#' },

{ '.', '.', '#', '.', '#', '.', '#', '#', '#', '#', '.', '#' },

{ '#', '#', '#', '.', '#', '.', '.', '.', '.', '#', '.', '#' },

{ '#', '.', '.', '.', '.', '#', '#', '#', '.', '#', '.', '.' },

{ '#', '#', '#', '#', '.', '#', '.', '#', '.', '#', '.', '#' },

{ '#', '.', '.', '#', '.', '#', '.', '#', '.', '#', '.', '#' },

{ '#', '#', '.', '#', '.', '#', '.', '#', '.', '#', '.', '#' },

{ '#', '.', '.', '.', '.', '.', '.', '.', '.', '#', '.', '#' },

{ '#', '#', '#', '#', '#', '#', '.', '#', '#', '#', '.', '#' },

{ '#', '.', '.', '.', '.', '.', '.', '#', '.', '.', '.', '#' },

{ '#', '#', '#', '#', '#', '#', '#', '#', '#', '#', '#', '#' }

};

//set starting and ending points

int startRow = 2;

int startCol = 0;

int endRow = 4;

int endCol = 11;

SECOND MAZE LAYOUT

//Establish fixed maze '#' is a wall, '.' is a path

char maze[12][12] = {

{ '#', '#', '#', '#', '#', '#', '#', '#', '#', '#', '#', '#' },

{ '#', '.', '.', '.', '#', '.', '.', '#', '.', '.', '.', '#' },

{ '.', '.', '#', '.', '#', '.', '#', '#', '.', '#', '.', '#' },

{ '#', '#', '#', '.', '.', '.', '.', '.', '.', '#', '.', '#' },

{ '#', '.', '.', '.', '.', '#', '#', '#', '.', '#', '.', '.' },

{ '#', '#', '#', '#', '.', '#', '.', '#', '.', '#', '.', '#' },

{ '#', '.', '.', '#', '.', '#', '.', '#', '.', '#', '#', '#' },

{ '#', '#', '.', '#', '.', '#', '.', '#', '.', '#', '.', '#' },

{ '#', '.', '.', '.', '.', '.', '.', '#', '.', '#', '.', '#' },

{ '#', '#', '#', '#', '#', '#', '.', '#', '.', '#', '.', '#' },

{ '#', '.', '.', '.', '.', '.', '.', '#', '.', '.', '.', '#' },

{ '#', '#', '#', '#', '#', '#', '#', '#', '#', '#', '#', '#' }

};

//set starting and ending points

int startRow = 2;

int startCol = 0;

int endRow = 4;

int endCol = 11;

THIRD MAZE LAYOUT

//Establish fixed maze '#' is a wall, '.' is a path

char maze[12][12] = {

{ '#', '#', '#', '#', '#', '#', '#', '#', '#', '#', '#', '#' },

{ '#', '.', '.', '.', '#', '.', '.', '#', '.', '.', '.', '#' },

{ '#', '.', '#', '.', '#', '.', '#', '#', '.', '#', '.', '#' },

{ '#', '#', '#', '.', '#', '.', '.', '.', '.', '#', '.', '#' },

{ '#', '.', '.', '.', '.', '#', '.', '#', '.', '#', '.', '#' },

{ '#', '.', '#', '#', '.', '#', '.', '#', '.', '#', '.', '#' },

{ '#', '.', '.', '#', '.', '#', '.', '#', '.', '#', '#', '#' },

{ '#', '#', '.', '#', '.', '#', '.', '#', '.', '#', '.', '.' },

{ '#', '.', '.', '.', '.', '.', '.', '#', '.', '#', '.', '#' },

{ '#', '#', '.', '#', '#', '#', '.', '#', '.', '#', '.', '#' },

{ '.', '.', '.', '.', '.', '#', '.', '#', '.', '.', '.', '#' },

{ '#', '#', '#', '#', '#', '#', '#', '#', '#', '#', '#', '#' }

};

//set starting and ending points DIFFERENT!

int startRow = 10;

int startCol = 0;

int endRow = 7;

int endCol = 11;

SAMPLE OUTPUT

# # # # # # # # # # # # # . . . # . . # . . . # # . # . # . # # . # . # # # # . # . . . . # . # # . . . . # . # . # . # # . # # . # . # . # . # # . . # . # . # . # # # # # . # . # . # . # . . # . . . . . . # . # . # # # # # # # # # # # # # ...cutting out the intermediate steps # # # # # # # # # # # # # . . . # . . # . . . # # . # . # . # # . # . # # # # . # . x x x # . # # . . . . # x # x # . # # . # # . # x # x # . # # . . # . # x # x # # # # # . # . # x # x # x > # . x x x x ~ # x # x # # # x # # # ~ # x # x # x x ~ ~ ~ # ~ # ~ x ~ # # # # # # # # # # # # # # # . # # # . # . # . # > . . . . # . # . . . # # # # # # # # # # # # #

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!