Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

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

Financial management theory and practice

Authors: Eugene F. Brigham and Michael C. Ehrhardt

12th Edition

978-0030243998, 30243998, 324422695, 978-0324422696

Students also viewed these Programming questions

Question

You are

Answered: 1 week ago