→This assignment is due by Friday, July 22, 2022 11:59 PM.←
→ As with all assignments, this must be an individual effort and cannot be pair programmed. Any debugging assistance must follow the course collaboration policy and be cited in the comment header block for the assignment.←
→ Do not forget to complete the following labs with this set: L5A,
L5B,
L5C
←
· Instructions · Rubric ·Submission ·
We will now combine the two-dimensional lists, stacks, and queues to implement a Maze solver using Breadth-First Search and Depth-First Search. The maze will be represented as a 2D List. The goal is to determine if it is possible to move from the Start Space to the End Space.
Create the Maze
Mazes will be specified in an external file. The format of the 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
.
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.
Solve the Maze (Maybe)
After the maze has been successfully read into memory, ask the user how they wish to solve the maze. Either by BFS or by DFS.
Based on the user's selection, search the maze using BFS with a Queue or DFS with a Stack as appropriate. Being your search at
the S
space and continue until the E
space is reached or the search is exhausted.
When the search is complete, print out if the maze can be solved or not.
Then print out the maze showing which locations were visited. Use @
to show which .
spaces
were visited by the search.
An example of a successful search is shown below:
> ./A6 input/1.maze
Opening file "input/1.maze"
File opened successfully!
Enter 1 to search via BFS.
Enter 2 to search via DFS.
Choice: 1
End was reached!
#########
#S#@@@#E#
#@#@#@#@#
#@#@#@#@#
#@@@#@@@#
#########
An example of an unsuccessful search is shown below:
> ./A6 input/4.maze
Opening file "input/4.maze"
File opened successfully!
Enter 1 to search via BFS.
Enter 2 to search via DFS.
Choice: 1
End cannot be reached
##########################
#S#@@@@@@@@@@@@#@@@@#@##.#
#@#@@@###@@@@###@##@#@#.E#
#@#@###@#@@#@@@#@##@#@##.#
#@@@@@#@@@###@@@@#@@@@####
###@##@@##@#@@####@##@####
###@@##@@@@####@@@@#######
##########################
To aide in testing your searches through various scenarios and conditions, a maze pack has been provided with 10 public test cases.
Hints
- Be very careful with passing objects to a function. If you pass an object to a function by value, then the copy constructor is called and any manipulations to the target will result in the copy being modified. The argument will remain unmodified. When dealing with objects as parameters, we'll want to be using either pass-by-reference or pass-by-pointer.
Best Practices To Follow
- One clear and consistent coding style used (such as K&R, 1TBS, or Allman).
- Code is self-documenting. Variables sensibly named, function names descriptive of their purpose.
- Keep your headers clean. Put the absolute minimum required in your headers for your interface to be used. Anything that can go in a source file should. Don't #include any system headers in your .h files that aren't absolutely required in that file specifically.
- Implement the Big-3 as appropriate.
- Use const wherever possible. If your function takes a parameter and does not modify it, it should be const.
- Don't leak memory. Every allocation using
new
needs to have a correspondingdelete
. - Don't use global variables. Instead, encapsulate it and design your interfaces effectively.
Testing
The graders will build your program with the Makefile you provide to match your code structure.
Grading Rubric
Your submission will be graded according to the following rubric.
Points | Requirement Description |
7 | Solves a maze with walls and no loops using BFS & DFS. |
7 | Solves a maze with walls and loops using BFS & DFS. |
7 | Solves a maze with no walls using BFS & DFS. |
7 | Solves a maze with no solution using BFS & DFS. |
2.5 | Public mazes solved correctly (0.25 per maze). |
2.5 | Private mazes solved correctly (0.5 per maze). |
5 | The above items make up 33/38 points towards the assignment. The rest of the assignment grade is based on how well the best practices are followed:
|
15 | All labs completed and submitted L5A, L5B, L5C |
53 | Total Points |
→This assignment is due by Friday, July 22, 2022 11:59 PM.←
→ As with all assignments, this must be an individual effort and cannot be pair programmed. Any debugging assistance must follow the course collaboration policy and be cited in the comment header block for the assignment.←
→ Do not forget to complete the following labs with this set: L5A,
L5B,
L5C
←
Submission
Always, always, ALWAYS update the header comments at the top of your main.cpp file. And if you ever get stuck, remember that there is LOTS of help available.
It is critical that you follow these steps when submitting homework.
If you do not follow these instructions, your assignment will receive a major deduction. Why all the fuss? Because we have several hundred of these assignments to grade, and we use computer tools to automate as much of the process as possible. If you deviate from these instructions, our grading tools will not work.
Submission Instructions
Here are step-by-step instructions for submitting your homework properly:
-
Make sure you have the appropriate comment header block at the top of every source code file for this set. The header
block should include the following information at a minimum.
Be sure to fill in the appropriate information, including:/* CSCI 261: Assignment 5: A5 - A-MAZE-ing
* * Author: XXXX (INSERT_NAME) * Resources used (Office Hours, Tutoring, Other Students, etc & in what capacity): * // list here any outside assistance you used/received while following the * // CS@Mines Collaboration Policy and the Mines Academic Code of Honor * * XXXXXXXX (MORE_COMPLETE_DESCRIPTION_HERE) */- Assignment number
- Assignment title
- Your name
- If you received any type of assistance (office hours - whose, tutoring - when), then list where/what/who gave you the assistance and describe the assistance received
- A description of the assignment task and what the code in this file accomplishes.
Additionally, update theMakefile
for A5 to generate a target executable namedA5
.
- File and folder names are extremely important in this process.
Please double-check carefully, to ensure things are named correctly.
- The top-level folder of your project must be named
Set5
- Inside
Set5
, create 4 sub-folders that are required for this Set. The name of each sub-folder is defined in that Set (e.g.L5A
,L5B
,L5C
, andA5
). - Copy your files into the subdirectories of
Set5
(steps 2-3), zip thisSet5
folder (steps 4-5), and then submit the zipped file (steps 6-11) to Canvas. - For example, when you zip/submit
Set5
, there will be 4 sub-folders calledL5A
,L5B
,L5C
, andA5
inside theSet5
folder, and each of these sub-folders will have the associated files.
- The top-level folder of your project must be named
- Using Windows Explorer (not to be confused with Internet Explorer), find the files
named
main.cpp, Makefile, README.txt, *.hpp, *.h, *.cpp
.
STOP: Are you really sure you are viewing the correct assignment's folder? - Now, for A5, right click on
main.cpp, Makefile, README.txt, *.hpp, *.h, *.cpp
to copy the files. Then, return to theSet5/A5
folder and right click to paste the files. In other words, put a copy of your homework'smain.cpp, Makefile, README.txt, *.hpp, *.h, *.cpp
source code into theSet5/A5
folder.
Follow the same steps for each lab to put a copy of each lab's deliverable into theSet5/L5
folders. Do this process forSet5/L5A
(main.cpp
),Set5/L5B
(main.cpp, Makefile, *.hpp, *.h, *.cpp
),Set5/L5C
(main.cpp, Makefile, *.hpp, *.h, *.cpp
).
STOP: Are you sure yourSet5
folder now has all your code to submit?
- Now, right-click on the
"Set5"
folder.- In the pop-up menu that opens, move the mouse
"Send to..."
and expand the sub-menu. - In the sub-menu that opens, select
"Compressed (zipped) folder"
.
STOP: Are you really sure you are zipping aSet5
folder with sub-folders that each contain amain.cpp
file in it?
- In the pop-up menu that opens, move the mouse
- After the previous step, you should now see a
"Set5.zip"
file.
- Now visit the Canvas page for this course
and click the
"Assignments"
button in the sidebar.
- Find Set5, click on it, find the
"Submit Assignment"
area, and then click the"Choose File"
button.
- Find the
"Set5.zip"
file created earlier and click the"Open"
button.
STOP: Are you really sure you are selecting the right homework assignment? Are you double-sure?
- WAIT! There's one more super-important step. Click on the blue
"Submit Assignment"
button to submit your homework.
- No, really, make sure you click the
"Submit Assignment"
button to actually submit your homework. Clicking the"Choose File"
button in the previous step kind of makes it feel like you're done, but you must click the Submit button as well! And you must allow the file time to upload before you turn off your computer!
- Canvas should say "Submitted!". Click "Submission Details" and you can download the zip file you just submitted. In other words, verify you submitted what you think you submitted!
In summary, you must zip the "Set5"
folder
and only the "Set5"
folder, this zip folder must have several sub-folders, you must name all these folders correctly, you must submit the correct zip file for this
homework, and you must click the "Submit Assignment"
button. Not doing these steps is like bringing your
homework to class but forgetting to hand it in. No concessions will be made for
incorrectly submitted work. If you incorrectly submit your homework, we will not be able to
give you full credit. And that makes us unhappy.
→This assignment is due by Friday, July 22, 2022 11:59 PM.←
→ As with all assignments, this must be an individual effort and cannot be pair programmed. Any debugging assistance must follow the course collaboration policy and be cited in the comment header block for the assignment.←
→ Do not forget to complete the following labs with this set: L5A,
L5B,
L5C
←