You can start with the code in maze.h, maze.cpp, and mazemain.cpp. When compiled, this program will read a maze from the specified text file and print the resulting maze to standard output. See the comments in the source files for more details.
Number of rows Number of columns For each row, each square in the row is represented by a hexadecimal digit.
The hexadecimal digits are obtained like this: Start with 0 If the square has a top wall, add 1 If the square has a right-hand wall, add 2 If the square has a bottom wall, add 4 If the square has a left-hand wall, add 8 Write the resulting number (0-15) as a hexdecimal digit (0-9, A, B, C, D, E, or F).For example, a 2x3 maze with exterior but no interior walls (that is, an empty 2x3 room) would be represented by:
2 3 9 1 3 C 4 6You don't have to parse this file format--that's what operator>> already does--but you might want to create example mazes for testing.
3 7 3 B D 1 5 1 3 A C 1 6 9 6 E C 5 4 7 C 5 5
Then your program, when run with maze.txt as a command-line argument, should print out the following:
+---+---+---+---+---+---+---+ * | | * * * | + + +---+ +---+ + + | * | * * | * * | | + +---+ +---+ +---+---+ | * * * | * * * +---+---+---+---+---+---+---+
Here, the *'s mark the path from the upper left to the bottom right.
Here's a pseudo-code algorithm that should do the job for you. To implement this algorithm, you'll need to make modifications to the MazeSquare struct and the Maze class.
Otherwise, let T = the top square on the stack. If T is the bottom right square of the maze, END.
Otherwise, select a square S that is adjacent to T, unvisited, and accessible from S (no wall between them). Mark S as visited and push it on the stack. Go to Test.
If your maze has no solutions, your program should halt, printing the maze with no *'s.
If you make some good test mazes, share them with each other. Putting together the text form of a maze is kind of a pain.
Have fun, start early, and keep in touch.