Previous: P4, Next: P6

Back to week 10 page: Link

Official Due Date: August 16

# Programming Problem Instruction

📗 Enter your ID here: and click
📗 The same ID should generate the same set of parameters. Your answers are not saved when you close the browser. You could either copy and paste your console output into the text boxes or print your output to text files (.txt) and load them using the button above the text boxes.
📗 Please report any bugs on Piazza.

# Warning: please enter your ID before you start!


📗 (Introduction) In this programming homework, you create a random maze and compare multiple uninformed and informed search algorithms.

📗 (Part 1) Create a \(h\) = by \(w\) = (height by width) rectangular orthogonal maze by parsing an image from the the Maze Generator: Link. You can also generate a random maze yourself using Recursive Backtracker or one of the Minimum Spanning Tree algorithms (Kruskal or Prim): Wikipedia or Link. Make sure you enter from the center cell of the top row and exit from the center cell of the bottom row.

📗 (Part 1) Plot the maze using | for vertical walls and -- for horizontal walls and + for intersections. Below is an 15 by 15 example of such plot and the solution.
Example:
Solution:

📗 (Part 1) Use BFS and DFS to get the solution of the maze. Keep track of the cells you searched (checked goal on).

📗 (Part 2) Use A* with the heuristic of Manhattan distance to the goal and Euclidean distance to the goal. Keep track of the cells you searched (checked goal on).

# Submission

# Question 1 [2 points]

📗 (plot) Enter the plot of the maze (use the same format as the example).




# Question 2 [5 points]

📗 (succ) Enter the successor matrix of the maze (\(h\) lines, each line containing \(w\) strings, comma separated, each strings represent the list of possible successors, a subset of the characters "U" "D" "L" "R").




# Question 3 [5 points]

📗 (solution) Enter the action sequence (one line, a sequence of characters "U" "D" "L" "R", no comma in between them). 
📗 Note: do not start or finish outside the maze.




# Question 4 [5 points]

📗 (plot_solution) Enter the plot of the maze with the solution (use the same format as the example).




# Question 5 [5 points]

📗 (bfs) Enter the list of states searched by BFS (\(h\) lines, each line containing \(w\) integers either 0 or 1, 1 means searched, comma separated).






# Question 6 [5 points]

📗 (dfs) Enter the list of states searched by DFS (\(h\) lines, each line containing \(w\) integers either 0 or 1, 1 means searched, comma separated)..






# Question 7 [5 points]

📗 (distances) Enter the Manhattan distances to the goal for each cell in the maze (\(h\) lines, each line containing \(w\) integers, comma separated).




# Question 8 [5 points]

📗 (a_manhattan) Enter the list of states searched by A* with Manhattan distance to the goal as the heuristic (\(h\) lines, each line containing \(w\) integers either 0 or 1, 1 means searched, comma separated).






# Question 9 [5 points]

📗 (a_euclidean) Enter the list of states searched by A* with Euclidean distance to the goal as the heuristic (\(h\) lines, each line containing \(w\) integers either 0 or 1, 1 means searched, comma separated)..






# Question 10 [1 points]

📗 Please enter any comments and suggestions including possible mistakes and bugs with the questions and the auto-grading, and materials relevant to solving the question that you think are not covered well during the lectures. If you have no comments, please enter "None": do not leave it blank.
📗 Answer: .

# Grade


 ***** ***** ***** ***** ***** 

 ***** ***** ***** ***** ***** 
📗 Warning: grading may take around 5 to 10 seconds. Please be patient and do not click "Grade" multiple times.

📗 Please copy and paste the text between the *****s (not including the *****s) and submit it on Canvas, P5.
📗 Please submit your code and outputs on Canvas, P5S.
📗 You could also save your output as a single text file using the button and submit this to P5S (with your code).
📗 Warning: the load button does not function properly for all questions, please recheck everything after you load. You could load your answers using the button from the text field:


📗 Saving and loading may take around 5 to 10 seconds. Please be patient and do not click the buttons multiple times.

# Hints and Solutions (frequently updated)

📗 Currently, the grading for checking the searched cells for DFS is very lenient because you can use different tie breaking rule that results in very different expansion paths.
📗 A maze is valid only if every cell is accessible: for example, you cannot just have a straight path from the entry to the goal. There should not be a region of connected empty cells too, but the grader is not explicitly checking it.
📗 You could either have U as a successor of the entry cell and D as a successor of the exit cell or not including them as successors. The auto-grader error forcing U and D as successors is fixed.
📗 For A* search you need to take the sum of the current cost and heuristic (either Manhattan distance or Euclidean distance from the current cell to the goal state). 
📗 It turns out Greedy search is very fast and efficient too, you can try it and plot the searched cells too. The video going through the TA's solution uses Greedy search instead of the A* with Euclidean distance.
📗 A sample solution in Java and Python is posted below.
Important notes: 
(1) Printing the maze using the correct format is not included.
(2) The Euclidean distance A* search code is not included, but you just need to modify the one for the Manhattan distance slightly.
(3) You are allowed to copy and use parts of the TA's solution without attribution. You are allowed to use code from other people and from the Internet, but you must state in the comments clearly where they come from!

Python code by Hugh Liu: Link
Java code by Ainur Ainabekova: Link.






Last Updated: November 09, 2021 at 12:30 AM