2005 Fall CSC1107 Project 2: Solve a Maze Given on 10/26(Wed), Due on midnight of 11/9 (Wed) Problem Given the starting point in a maze, you are to find and mark a path out of the maze. The maze is represented by a nxm array of 1’s(representing hedges) and 0’s(representing the foot-paths). There is only one exit from the maze (represented by E). You may move vertically or horizontally in any direction that contains a 0; you may not move into a square with a 1. If you move into the square with an E, you have exited the maze. If you are in a square with 1s on three sides, you must go back the way you came and try another path. You may not move diagonally. For this program, a stack class should be used. Input: Input is a text file that is composed of two parts as following. 1. First line has two numbers that mean the dimension of the maze 2. Followed by array of characters (1s, 0s, and E) For example: 10 20 00001110000000100100 11100011101110001111 11111000101000111000 00001110101100010010 01011000101111000110 00001110000110011110 11011100110110111000 00011110110110111101 01011011110110100000 0100000000011011011E In the array part, each data line consists of one row of maze. Starting points (i.e. a row, column pair) in the maze will be input from the keyboard. Output: Print the original maze with numbered rows and columns prior to asking the user for their starting point. For each entry into the maze, print the complete maze with an S in the starting point followed by the words ‘I am free’ if you have found a path out of the maze or the words ‘Help, I am trapped’ if you cannot. You must also print the path (by using a series of pluses(+)) you took through the maze should one be found. For instance, if the input starting point is 4,1 the output should be like as following I am free 000011100+++++100100 111000111+111+001111 111110001+100+111+++ S++011101+110++1++1+ 01+110001+1111+++11+ 00+011100++11001111+ 11+1110011+1101110++ 00+1111011+1101111+1 01+1101111+1101000++ 01+++++++++11011011E Here is a summary of algorithm: 1. At the beginning position, examine the four adjacent squares and push onto the move stack the ones with a 0 or E in them. 2. In order to move, pop one square from the stack (Stack1). If stack is empty (when this happens it means that your are surrounded by 1s and/or +s), you are trapped. Mark the square we are in as having been visited by putting a + in the square. 3. Get the next move from the stack and make the square whose coordinates have just been popped the current square. 4. Repeat the process until you either reach the exit point or try to back track and the stack 5. Note that the above algorithm does not explain how one determines and marks the path to the exit from the starting point.