Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

DCODE IN C + + ! ! ! ! RECURSAL MAZE Do not solve this project with recursion. Instead, follow the right - hand rule

DCODE IN C++!!!!RECURSAL MAZE 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.
mazelayout1.h :
//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;
image text in transcribed

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

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

Recommended Textbook for

50 Tips And Tricks For MongoDB Developers Get The Most Out Of Your Database

Authors: Kristina Chodorow

1st Edition

1449304613, 978-1449304614

More Books

Students also viewed these Databases questions

Question

How do taxes affect the cost of debt?

Answered: 1 week ago

Question

=+2. Who are the key publics for this situation?

Answered: 1 week ago

Question

Create a class diagram with UML tools.

Answered: 1 week ago