Question
URGENT!!!!! I need to develop a C++ program that uses a recursive function to solve this maze problem: (No classes please!!!!) A robot is asked
URGENT!!!!!
I need to develop a C++ program that uses a recursive function to solve this maze problem:
(No classes please!!!!)
A robot is asked to navigate a maze. It is placed at a certain position (the starting position) in the maze and is asked to try to reach another position (the goal position). Positions in the maze will either be open or blocked with an obstacle. Positions are identified by (x,y) coordinates. At any given moment, the robot can only move 1 step in one of 4 directions. Valid moves are:
Go North: (x,y) -> (x,y-1) Go East: (x,y) -> (x+1,y) Go South: (x,y) -> (x,y+1) Go West: (x,y) -> (x-1,y)
Note that positions are specified in zero-based coordinates (i.e., 0...size-1, where size is the size of the maze in the corresponding dimension).
The robot can only move to positions without obstacles and must stay within the maze.
The robot should search for a path from the starting position to the goal position (a solution path) until it finds one or until it exhausts all possibilities. In addition, it should mark the path it finds (if any) in the maze.
To make this problem more concrete, let's consider a maze represented by a matrix of characters. An example 6x6 input maze is:
S##### .....# #.#### #.#### 'S' - start position (here, x=0, y=0) ...#.G
'G' - goal (here, x=5, y=4) A path in the maze can be marked by the '+' symbol...
A path refers to either a partial path, marked while the robot is still searching:
+#####
++++.# (i.e., one that may or may #.#### #.#### not lead to a solution). Or,
...#.G a solution path: ##...#
S##### which ++...# #+#### leads from #+####
.++#+G ##+++#
##...#
'.' - where the robot can move (open positions) '#' - obstacles (blocked positions)
Thank you, I will upvote your answer if it works and is correct
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started