Provided Code Skeleton
We have provided
( tar file or zip file)
all the code to get you started on your MP, which
means you will only have to write the search functions. Do not
modify provided code. You will only have to modify search.py.
maze.py
- getStart() :- Returns a tuple of the starting position, (row, col)
- getObjectives() :- Returns a list of tuples that correspond to the dot positions, [(row1, col1), (row2, col2)]
- isValidMove(row, col) :- Returns the boolean True if the (row, col) position is valid. Returns False otherwise.
- getNeighbors(row, col) :- Given a position, returns the list of tuples that correspond to valid neighbor positions. This will return at most 4 neighbors, but may return less.
search.py
There are 4 methods to implement in this file, namely bfs(maze),
dfs(maze), greedy(maze), and astar(maze).
(You may need to add another named search method if you
implement an additional search method for extra credit.)
Each of these
functions takes in a maze instance, and should return both the path
taken (as a list of tuples) and the number of states explored. The
maze instance provided will already be instantiated, and the above
methods will be accessible.
To understand how to run the MP, read the provided README.md or
run python3 mp1.py -h into your terminal. The following
command will display a maze
and let you create a path manually using the arrow keys.
python3 mp1.py --human maze.txt
The following command will run your astar search method on the maze.
python3 mp1.py --method astar maze.txt
You can also save your output picture as a file in tga format.
If your favorite document formatter doesn't handle tga, tools such as
gimp can convert it to other formats (e.g. jpg).
Tips
- In your implementation, make sure you get all the bookkeeping right. This includes handling
of repeated states (in particular, what happens when you find a better
path to a state already on the frontier) and saving the optimal solution
path.
- Pay attention to tie-breaking. If you have multiple nodes on the
frontier with the same minimum value of the evaluation function, the
speed of your search and the quality of the solution may depend on
which one you select for expansion.
- Implement all four strategies using a similar approach and coding style.
In particular, while DFS can be implemented very compactly using recursion,
you must store the frontier in an explicit stack, queue or priority queue (depending on the search algorithm) for this assignment.
Among other things, limits on recursion depth can be (depending on your installation)
much lower than
the number of objects that you can pack into an explicit stack.
- You will be graded primarily on the correctness of your solution, not on the
efficiency and elegance of your data structures. For example, we don't
care whether your priority queue or repeated state detection uses
brute-force search, as long as you end up expanding exactly the
correct number of nodes (except for small differences caused by differences among tie-breaking strategies)
and find the optimal solution. So, feel free
to use "dumb" data structures as long as it makes your life easier
and still enables you to find the solutions to all the inputs in a reasonable
amount of time.
Report Checklist
Your report should briefly describe
your implemented solution and fully answer the questions for every part of the assignment. Your description
should focus on the most "interesting" aspects of your solution, i.e., any non-obvious
implementation choices and parameter settings, and what you have found to be especially
important for getting good performance. Feel free to include pseudocode or figures if
they are needed to clarify your approach. Your report should be self-contained and it should
(ideally) make it possible for us to understand your solution without having to run your source code.
Kindly structure the report as follows:
- Title Page:
List of all team members, course number and section for which each member is registered, date on which the report was written
- Section I:
Algorithms (Search). This section should describe algorithms and data structures used for all four search strategies.
Answer questions like: what is a state? what is a node? are they the same or different in your implementations? What is the frontier?
Do you maintain an explored states list? How are repeated states detected and managed?
- Section II:
Algorithms (A* and Greedy BFS). This section should describe the heuristic(s) used for A* and Greedy BFS, for both the single dot and multiple-dot situations
Provide proof that the heuristics for A* are admissible
- Section III:
Results (Basic Pathfinding). For every algorithm in part 1, (DFS, BFS, Greedy, A*), and every one of the mazes,
(medium, big, open), give the maze screenshot with the computed path, the solution cost and the number of expanded nodes (12 cases total)
- Section IV:
Results (Search with multiple dots). For part 2, for each of three mazes (tiny, small, medium), give the solution screenshot, solution cost, and number of expanded nodes for your A* algorithm.
- Extra Credit:
If you have done any work which you think should get extra credit, describe it here
- Statement of Contribution:
Specify which team-member performed which task. You are encouraged to make this a many-to-many mapping, if applicable.
e.g., You can say that "Rahul and Jason both implemented the BFS function, their results were compared for debugging and Rahul's code was submitted.
Jason and Mark both implemented the DFS function, Mark's code never ran successfully, so Jason's code was submitted. Section I of the report was written by all 3 team members.
Section II by Mark and Jason, Section III by Rahul and Jason.".. and so on.
WARNING: You will not get credit for any solutions that you have obtained,
but not included in your report!
For example, you will lose points if your code prints out path cost and
number of nodes expanded on each input,
but you do not put down the actual numbers in your report.
Your report must be a formatted pdf document.
Pictures and example outputs
should be incorporated into the document.
Exception: items which are very large or unsuitable for inclusion in a pdf document
(e.g. videos or animated gifs) may be put on the web and a URL included in your report.
Extra credit:
We reserve the right to give bonus points for any advanced
exploration or especially challenging or creative solutions that you implement.
This includes, but is not restricted to, the extra credit suggestion given above.