Fefe
Fefe
Homework #1 – Maze
Due: 21 March 2024, Thursday, 22:00
Brief Description
In this homework, first, you will implement a program which will generate a random maze of size MxN,
where M represents the number of rows, and N represents the number of columns. Then, you will also
need to implement a function which will find the path between designated entry and exit points in a
given maze.
To do this homework, you are required to implement a Stack using a LinkedList data structure, i.e., you
can not use vectors in the stack implementation. The stack class MUST be a template-based class. You
may want to store basic data types, structs or classes in this stack.
The Maze
The mazes are presented as MxN (M rows and N columns) 2D vectors as given below. The left bottom of
the mazes are considered to be the (0,0) coordinate. There are 2 important rules for a given 2D vector to
be a maze:
Some example mazes of size 5x5 and 3x6 can be found below. Note there are no entry or exit points yet.
We also share some invalid maze examples below. In both mazes, for some cell pairs (c1 ,c2), there are
more than one path to reach from c1 to c2.
Program Flow
There are 2 phases of this homework;
In both phases, you MUST use the stacks to solve the problem!
● All the inputs entered by the user are valid, you do not need to validate them.
● The entry and exit points of the mazes are on the edges or corners of the mazes.
You will write your mazes into a file named as maze_mazeID.txt, where mazeID will go from 1 to K such
as maze_1.txt and maze_4.txt. Your output format must be exactly the same format as we give below. In
the first line, sizes of the maze, M and N, must be given. In the following lines, for each cell, the x and y
coordinates of the cell, as well as the walls of the cell, must be given. If there is a wall on the left (l), right
(r), up (u), or down (d), assign 1 to the wall, if not, assign 0. For example, in the maze_1.txt below, at
(0,0) cell, there are walls on the left, right and down side, but not on the up side.
maze_1.txt
5 4
x=0 y=0 l=1 r=1 u=0 d=1
x=1 y=0 l=1 r=0 u=1 d=1
x=2 y=0 l=0 r=0 u=1 d=1
…
In the second phase (after the mazes are generated), your program will ask the user to enter 5 more
inputs; mazeID, entryX, entryY, exitX, and exitY. Maze ID will be a number between 1 and K, i.e., 1 <=
mazeID <= K, indicating the specific mazes that are generated in the first phase to be traveled. For
example, if mazeID = 3, then, the program needs to find a path for the third maze. entryX and entryY are
the coordinates for entry point, and exitX and exitY are the coordinates for the exit point. Note that, y
coordinates become the row of the maze and x coordinates become the column of the maze. For
instance, the point (2,4) refers to the 4th row and 2nd column of the maze.
In the output file, the coordinates of the cells to get the exit point from entry point must be written line
by line. See example output file below:
maze_2_path_0_0_3_4.txt
0 0
…
…
3 4
On windows machine:
1. Put the mazeDrawer.exe and libpwinthread-1.dll along with the input files into the same folder.
a. Please note that mazeDrawer.exe and libpwinthread-1.dll need to be in the same folder
for your program to work.
2. Click on mazeDrawer.exe.
3. Follow the instructions as needed.
1. Put the mazeDrawer (mazeDrawer.mac for macOS and mazeDrawer.linux for Linux) program and
the input files into the same folder.
2. For macOS;
i. Open a Terminal.app
ii. Copy the folder with Command+C (this will copy the path to reach the folder)
iii. In terminal, type cd
iv. Use Command+V to paste the folder path and click enter
Example usage (assuming mazeDrawer.mac is in the following path):
cd /Users/oguzozsaygin/Homework1
For Linux;
i. Go to the folder.
ii. Right click anywhere in the folder.
iii. Click open a terminal .
3. Execute the following command on the terminal by typing:
a. For macOS;
./mazeDrawer.mac
b. For Linux;
./mazeDrawer.linux
4. Follow the instructions as needed.
If you face any issues running the mazeDrawer program, please go to an office hour or ask your TA to
explain it in the recitation.
You will be given the file maze_example.txt to draw the maze below as an example. Use it as a way to
understand how to use the program. This program is for you to better visualize your maze, though you
are not obligated, we highly recommend you to use it for debugging your code.
Sample Run
Enter the number of mazes: 5
Enter the number of rows and columns (M and N): 20 32
All mazes are generated.
Grading:
❑ Late penalty is 10% off the full grade and only one late day is allowed.
❑ Having a correct program is necessary, but not sufficient to get the full grade. Comments,
indentation, meaningful and understandable identifier names, informative introduction and
prompts, and especially proper use of required functions, unnecessarily long programs
(which is bad) and unnecessary code duplications will also affect your grade.
❑ Please submit your own work only (even if it is not working). It is really easy to find “similar”
programs!
❑ For detailed rules and course policy on plagiarism, please check out
http://myweb.sabanciuniv.edu/gulsend/courses/cs201/plagiarism/
Grade announcements: Grades will be posted in SUCourse, and you will get an Announcement at the
same time. You will find the grading policy and test cases in that announcement.
Grade objections: Since we will grade your homeworks with a demo session, there will be very likely no
further objection to your grade once determined during the demo.
Add your name to the program: It is a good practice to write your name and last name somewhere in the
beginning program (as a comment line of course).
Submission:
Submit via SUCourse ONLY! You will receive no credits if you submit by other means (e-mail,
paper, etc.).
Successful submission is one of the requirements of the homework. If, for some reason, you cannot
successfully submit your homework and we cannot grade it, your grade will be 0.
Good Luck!
Gülşen Demiröz