This lab is due by Thursday, May 04, 2023, 11:59 PM.
As with all labs you may, and are encouraged, to pair program a solution to this lab. If you choose to pair program a solution, be sure that you individually understand how to generate the correct solution.
The process of determing if a maze can be solved will be done in two phases. First, we will read in and visualize the maze. Then we will look for a path from start to end (if one exists).
Maze Files
A maze pack has been provided with many sample mazes. The format of the maze file is:
R C
#####
#S#E#
#...#
#####
The first line specifies the size of the maze as R
rows and C
columns. Next, an R
xC
2D array
of characters follow. The following properties describe the makeup of the character array:
#
- signifies a wall. These spaces are unable to moved to..
- signifies an open space. These spaces may be moved to.S
- signifies the starting space. You will begin your search from here. This space may be moved to.E
- signifies the end space. You will end your search here. This space may be moved to.- The maze will always be well-formed. Meaning, it will always be of size
R
xC
and only contain the four characters specified above. S
andE
will each always appear only one time in the maze.- The size of the maze will be bound by
3 ≤ R ≤ 102
and4 ≤ C ≤ 102
.
Loading the Maze
Begin by checking if a command line argument was specified with the filename. If not, prompt the user to enter a file containing the maze. As
you read the file, create a 2D list of characters that matches the size of the maze. Read the maze contents into your 2D list. Be sure to note
what location the S
character is in to start your upcoming search.
Drawing the Maze
Each space in our maze will be a 15x15 rectangle. Create an SFML window that has a width of 15*C
and height of 15*R
.
Inside of the draw loop, loop over every row & column in the maze array. Create a RectangleShape
that is sized and
positioned accordingly. Color the rectangle based on the value in the maze at that position:
- if the cell is
'S'
, then color it Green - if the cell is
'E'
, then color it Red - if the cell is
'#'
, then color it Black - if the cell is
'.'
, then color it White
The visualization of Maze 1 is shown below:
![Maze 1](images/maze1.png)
The visualization of Maze 4 is shown below:
![Maze 4](images/maze4.png)
Lab Submission
Submit your main.cpp, Makefile, *.h, *.cpp, *.hpp
file(s).
You will submit your solution to this lab with the rest of Set6. Detailed instructions for doing this are posted in Assignment 6.
This lab is due by Thursday, May 04, 2023, 11:59 PM.
As with all labs you may, and are encouraged, to pair program a solution to this lab. If you choose to pair program a solution, be sure that you individually understand how to generate the correct solution.