Question
Components: Read in the contents of the maze from a text file names maze.txt that will contain the contents below (two numbers for size, then
Components:
- Read in the contents of the maze from a text file names maze.txt that will contain the contents below (two numbers for size, then symbols for the maze itself)
- Starting at (1,1) determine if the maze is navigable or not
- If the maze is navigable, output a valid path.
Construct a program to aid in the navigation of a maze. A Maze can be defined in a file using X characters to represent walls, space characters to represent paths, and a $ character to represent the goal. For example:
8
10
XXXXXXXXXX
X X
XX XXX XXX
XX X X
XXXX X X X
X X XXX
X XXXX $X
XXXXXXXXXX
The starting point is assumed to be location (1, 1) and the maze is assumed to have a border. Make a program that displays the sequence of positions in a path from the start to the goal,or indicate if no path is available. For example, for the maze above, the program displays:
Path: (1,1) (1,2) (1,3) (1,4) (1,5) (1,6) (2,6) (3,6) (4,6) (5,6) (6,6) (6,7) (6,8)
Once the path is obtained, computer will simply follow it to obtain the reward.
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