Comp 1672, Sections 1 and 2, Winter 2002 Programming Assignment 2 Assigned January 16, 2002 Due Wednesday, January 30, 2002 All code must be written individually and independently. Mail your source code (header file and .cpp file or files) and the output files to comp1672@cs.du.edu before class on the due date. Turn in a hard copy of the header files and source code at the beginning of class on the due date. Include a separate document which explains your program - this should include an explanation of the input and output of your program, the structure of your program (including a brief explanation of each function, the variables you are using in your program, etc.) At the top of each file, put comments with your name, the date, course number, and assignment number. As always, write the program with a well organized structure, format it consistently, and document your program by naming functions and variables in a useful way, and by writing comments that would help someone understand how the code works so they could modify, enhance, or debug it. This program is based on problem 5.25 of Deitel and Deitel, but it has additional functionality. A maze can be represented as a grid of hashes (#) and dots (.) with the hashes representing the walls of the maze and the dots representing squares in the possible paths through the maze. This grid can be represented as a two-dimensional character array. Moves can only be made to the left, right, up or down from the current location, and only to a location in the array that contains a dot. (Diagonal moves are not allowed). Here's an example of a 12x12 maze (maze12.txt): Maze is 12 by 12 Maze entrance is at row 2, column 0 # # # # # # # # # # # # # . . . # . . . . . . # . . # . # . # # # # . # # # # . # . . . . # . # # . . . . # # # . # . . # # # # . # . # . # . # # . . # . # . # . # . # # # . # . # . # . # . # # . . . . . . . . # . # # # # # # # . # # # . # # . . . . . . # . . . # # # # # # # # # # # # # And here's an example of a 5x5 one (maze5.txt): Maze is 5 by 5 Maze entrance is at row 3, column 0 # # # . # # . . . # # . # . # . . # # # # # # # # Assume there is exacly one entrance and one exit, both at the edges of the maze. Then there is a simple algorithm for walking through the maze from the entrance to the exit. Place your right hand on the wall to your right and begin walking forward. Never remove your hand from the wall. If the maze turns to the right, you follow the wall to the right. As long as you do not remove your hand from the wall, eventually you will arrive at the exit of the maze. This algorithm does not necessarily give the shortest path. This assignment is to write a program that will traverse such a maze. You may choose whether your solution is iterative or recursive. Describe and explain this choice in your program explanation. The program should display the maze after each move so the user can watch as the maze is solved. As the program runs, it should place an "x" on each location it has traversed, and an "o" at the current location, The program should write this output to a file. The output should be a picture of the maze for each move in the traversal of the maze. Run your program with each of the two input files given above. Along with your source code, email the output files for each of these two mazes. The program should input the maze itself from a file - prompt the user for the name of the file. The format of the file will be: 1st line: Maze is n by n (where n indicates the size of the maze) 2nd line: Maze entrance is at row r, column c (where r and c give the starting location of the maze) Each of the 3rd line through (n+2)th line contains exactly n characters, either # OR ., defining the walls and paths in the maze. If there is an error in the format of the file, the program should detect this and prompt for another file. You can use a read-only variable to define the size of the maze and use this throughout the program. If you are in need of a further challenge after completing this program, please see me - I have an extension to this program that you will find difficult and fun!