Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Project description: Write a C++ program that, given a starting point, finds its way out of a maze. The maze's map will be read from

image text in transcribed
image text in transcribed
image text in transcribed
Project description: Write a C++ program that, given a starting point, finds its way out of a maze. The maze's map will be read from a file at the start of the program. Your code must work for all legal mazes. The maze is a rectangular grid represented as a 2D array, and the exit (if there is one) should be placed on an outer row or column of the play area (non-red cells below) The program should run until the exit to the maze is found or until it determines that there is no exit (after exploring all traversable cells). Exploration of the maze is done by recursively invoking a function and marking the cells visited with a special character (an electronic bread crumb to keep from reprocessing explored cells). The legal moves are to cells adjacent, but not diagonal, to the current cell. The maze should be solved through recursive calls and backtracking, and not by looking ahead. If the specially marked exit cell is encountered the game should exit with a message that the exit was found. Otherwise, after exploring the whole maze, a message is output stating that there is no exit At left is an instance of a maze. Note the attributes of a legal maze: X marks non-traversable cells-The cells in red are not part of the maze map read from the file, but must be constructed around it. They mark the boundary of the maze, and are represented as not traversable. The maze will always have two more columns and two more rows than the play ar read from the file (the maze at left has the maximum 8x8 play area, and fills the 10 x 10 array). Blue squares are walls. Play area are non-red cells .(yellow) shows traversable cells that have been previously visited. O cells (green) are traversable cells that have not been visited. Al traversable cells must be reachable from any other traversable cell E marks the exit (outlined gray cell)-If it exists, It must be placed on one of the outer rows or columns of the play area. The exit must be reachable from any traversable cells in the maze (it can't be contained within walls) Requirements: 1. Your program must be split into 3 files. There will be a class (with separate interface and implementation files), and a driver file. The requirements for these are specified below: a) The Maze class- This class represents a maze Files must be named maze.h and maze.cpp Class must be named Maze The interface (header file) is provided

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

How To Build A Million Dollar Database

Authors: Michelle Bergquist

1st Edition

0615246842, 978-0615246840

More Books

Students also viewed these Databases questions