This lab required us to use a 2 dimensional array to represent a maze. The array is passed to several functions, each performing a different task on the array. The createMaze function creates a maze of random size with random 1's and 0's. The nextMove function traces the solution path, by calling legalMove to see if the current position is barrier or nonbarrier. And the displayMaze function simply displays the solution in the correct format. .
I have chosen to use the rand() function to both determine the maze size, and fill the array with 1's and 0's. However, in the main I have used srand(time(NULL) to use the computers time (seconds) to set the seed. Rand() without srand() allows you to get the same numbers repeated, meaning it is not exactly random. Using the computers time to set the seed before calling rand() % 12, enabled a true random size. When assigning random 1's and 0's the srand() call was not needed. Rand() % 2 gave me random mazes each time the program was ran. .
I was not surprised with the results. I think my code does exactly what I had planned it to do. Originally I wasn't using the srand(time(NULL)) to set the seed. This was surprising me because my mazes were always the same. Setting the seed with the computers time solved this issue. The only remaining problem was encountering a dead end path, and trying a new starting point. .