Question: THIS IS A C++ ASSIGNMENT Programming assignment 10: Maze Solvability Assigned: 11/12 Checkin: 11/14 (by email by 5pm) - Start a new project, define your

THIS IS A C++ ASSIGNMENT

Programming assignment 10: Maze Solvability

Assigned: 11/12 Checkin: 11/14 (by email by 5pm) - Start a new project, define your maze class. Make sure you can load and display an ASCII map given a provided file Due: 11/19 by email before the start of class

Libraries you may use:

iostream

fstream

string

The use of any other libraries will result in the loss of points.

Purpose: The purpose of this assignment is to give us all a bit more practice working with recursion, specifically flood fill! In addition to performing traditional flood applications, a flood fill can be used to determine if it is possible to solve a maze: Start the flood at the 'Start' location, and see if your flood makes it to the 'end' location!

Task: First, you will need to define a maze class with the following member attributes and functionality:

Your maze class will minimally require the following attributes:

struct point - you will need to define a point struct, containing a row and a column. This will be used by your program to determine start and end locations.

pixel** plan - a dynamic 2D array that holding an ASCII representation of your maze

int rows - number of rows in your dynamic array

int cols - number of columns in your dynamic array

string outputFile - a string of the output file you will be generating. This will be derived from the input file (see constructor below). Simply add a ".flooded" to the end of the input file name.

point start - a row and column position of the starting point

point end - a row and a column position of the end point

Your maze class should also minimally contain the following member functions:

maze(string infile) - parameterized constructor. Note, there should be no default constructor. Open the file specified by infile, and read in the data. The first 2 values in the file will be cols then rows. The next 4 values will be row and colum pairs defining the start and end points of this maze. You will then need to create your dynamic 2D array and load data from the input file. It is safe to assume that a space means the area is clear, and pipes '|', hyphens '-', and plus signs '+' define maze walls/edges.

void flood(char c) - Your flood should start at point start, and should flood the maze with the character c.

void storeResult() - this function outputs your maze data to file. It should be in the same format you read it in, but show the results of the flood.

bool isSolveable(char c) - this function should check to see if the flood reached the end position. You will need to pass it the same character you used for the flood. It is a helper function so main() can check to see if the maze is solveable.

Your main file will be very sparse for this assignment: Start by asking the name of the file to load. You will use this information to create a maze object. Your main will then need to prompt the user for a flood character, flood it via the flood function, print out whether or not the maze is solveable, and then finally save it via the storeResult function. As such, you will not need to implement any further function in your main (unless you feel it would be helpful).

Sample text files:

Maze1.txt

31 65 29 0 29 64 +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+ | | | | + +--+ + +--+--+ +--+--+--+--+--+--+--+--+--+ +--+--+--+ + | | | | | | | | | +--+ + +--+ +--+--+ + + + + +--+--+--+ +--+ + +--+--+ | | | | | | | | | | | | | + +--+ + +--+ +--+--+--+--+--+--+ +--+--+ +--+--+--+ +--+ | | | | | | | | | | | | | + +--+--+ +--+ + +--+--+--+ + + + + +--+ + +--+--+ + | | | | | | | | | | | | + +--+ + + +--+--+ +--+ + +--+--+--+--+ + +--+--+--+--+ | | | | | | | | | | | + + +--+ +--+--+--+--+ + +--+--+--+--+ + +--+ +--+ +--+ | | | | | | | | | | + + + +--+--+--+--+--+--+--+ +--+--+ +- +--+ + + +--+ + | | | | | | | | | | + +--+--+ + + + +--+ +--+--+ +--+--+ + + +--+ + +--+ | | | | | | | | | | | | | | + + +--+--+ + +--+ + +--+--+--+ +--+--+--+ + + +--+ + | | | | | | | | | | | | | + + + +--+--+--+--+ +--+ + +--+--+--+--+ + +--+--+--+ + | | | | | | | | | | | + + +--+--+--+--+--+--+--+--+--+ +--+--+ +--+--+--+ +--+ + | | | | | | | | | | | | +--+--+--+ + + + + +--+ +--+ +--+ +--+ +--+--+ + +--+ | | | | | | | | | | | | | | | + +--+ +--+ + + + +--+--+--+--+--+ + +--+ + + +--+--+ | | | | | | | | | | | +--+--+--+ +--+ + +--+--+--+--+--+ + + +--+--+--+--+--+ + | | | | +-----+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+

maze2.txt

53 47 53 36 0 22 +--+--+--+--+--+--+--+ +--+--+--+--+--+--+--+ | | | | | | + +--+ +--+--+--+--+ +--+ + + + + + + | | | | | | | | +--+ +--+ + +--+--+--+ +--+--+--+ + + + | | | | | | | | | +--+--+ +--+ +--+ + +--+--+ + + + + + | | | | | | | | + +--+--+ +--+ + +--+ +--+--+ + +--+--+ | | | | | | | | | +--+--+--+--+ +--+--+ +--+ +--+ + + + + | | | | | | | | | + + + +--+ + + +--+ +--+ + +--+--+ + | | | | | | | | | | | + + +--+ + + +--+ +--+--+--+--+ + + + | | | | | | | | +--+--+ +--+--+--+ +--+ +--+--+ + +--+--+ | | | | | | | | | + + +--+ + + +--+--+--+ + + + + + + | | | | | | | | | | | + + + +--+--+ +--+--+ + + +--+--+--+ + | | | | | | | | | | + + + + + +--+ + +--+--+ +--+ + +--+ | | | | | | | | | | + +--+--+ + +--+--+--+--+ + + +--+--+ + | | | | | | | | | | + +--+ + +--+ + + + +--+--+ + + + + | | | | | | | | | | | | + + +--+ + +--+ +--+--+ + + + +--+ + | | | | | | | | | + + +--+ +--+ +--+--+--+--+ +--+ + + + | | | | | | | | + +--+ +--+--+--+ +--+--+ +--+ +--+--+--+ | | | | | | | + + +--+--+--+--+ + +--+--+ + +--+--+ + | | | | | | | | | | + +--+ + + + +--+ + +--+ +--+ + +--+ | | | | | | | | | | + +--+--+ + + + +--+--+ +--+ +--+--+ + | | | | | | | | | | + + + +--+ + + + + + +--+--+ + +--+ | | | | | | | | | | | + +--+--+ + + + + +--+ +--+--+--+ + + | | | | | | | | | | +--+--+ +--+--+ +--+ + + + +--+ + + + | | | | | | | | | | | + +--+--+ +--+ + +--+ + + + +--+ + + | | | | | | | | | | +--+--+ + + + +--+--+--+--+ + + + + + | | | | | | | | | | | + + + +--+ + +--+ + + + +--+ + +--+ | | | | | | | +--+--+--+--+--+--+--+--+--+--+--+ +--+--+--+

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!