Project One due Mon 10 Feb, 10AM

MCS 360 Project One : Finding a path through a maze, due Monday 10 February 2003, at 10AM.

The goal of this project is find a path through a maze, using a stack of coordinates.

The maze is presented by a square matrix of spaces and plusses. Open space is represented by spaces, plusses represent the walls. A walk through an n-by-n maze starts at position (0,0) and ends at position (n-1,n-1). The dimension n of the maze is given by the user. Let the computer then create an n-by-n maze, using a random number generator. Make sure that positions (0,0) and (n-1,n-1) are free. Here is an example of a 5-by-5 maze:

   + +    
   +   + +
          
     + + +
 + + +    
We immediately see that there is no path from the upper left to the lower right corner. In this case, after printing the generated maze, the program terminates printing the sentence
No path found.

At any position (i,j), there are eight possible moves:

     (i-1,j-1)     (i-1,j)     (i-1,j+1)
     northwest      north      northeast

     (i,j-1)        (i,j)      (i,j+1)
      west         current      east

     (i+1,j-1)     (i+1,j)     (i+1,j+1)
     southwest      south      southeast
The order of the moves is important for the termination of the algorithm. It is forbidden to leave the maze or to move to a spot where there is a wall.

Correct programs that do not use a stack or any function definitions at all will be discounted with ten points. A correct program does not contain spelling or grammar mistakes in the dialogue with the user.

The first line of your program should be like

                     /* MCS 360 Project One by <Author> */
where you replace the <Author> by your name. The gcc (or g++) compiler will be used to test your program. So even if you have developed your program in a Windows environment, test your code on icarus.cc.uic.edu with gcc (or g++).

Following is a ``screenshot'' of a session with the program:

Give the size of the maze : 5
Generated the maze :
   +     +
 +   +   +
         +
 +     +  
          
Found a path through the maze : 
  (4,4) with move = 5 south
  (3,4) with move = 0 northwest
  (2,3) with move = 4 southeast
  (1,3) with move = 5 south
  (0,3) with move = 5 south
  (0,2) with move = 3 east
  (1,1) with move = 2 northeast
  (0,0) with move = 4 southeast
Path through the maze : 
 x + x x +
 + x + x +
       x +
 +     + x
         x
The printout of your program will be collected at the start of the lecture on Monday 10 February, at 10AM. Before the deadline, send the code by e-mail to janv@uic.edu from your account on icarus. Put the files ``stack.h'', ``stack.c'' and the main program all in one file: proj1.c. To ensure that after putting these three files in one, the file proj1.c still compiles, you may have to comment out certain headers. Send your program typing on icarus the following command :
                     mail janv@uic.edu < proj1.c
This ensures your program is free from any encapsulations. Note that the e-mail address is my university netid and not the address at the MSCS department. Please e-mail your program only once.

If you have questions, comments, or difficulties, feel free to come to my office for help.