CSCI 335 - Artificial Intelligence
Fall 2011
Programming Assignment #1: Solving Mazes with A*
Overview
You will develop a series of search heuristics for solving a maze.
You will be provided with the code for representing mazes and
generating random mazes. You will develop a best-first search implementation,
along with several heuristics. Mazes can be of different levels of
"perfection", and they can also contain treasures that must be obtained.
Here are the provided source files:
Programming Assignment
Implement the following heuristics:
- A simple breadth-first search heuristic
- A heuristic that in some way uses a Manhattan distance calculation
- Two additional monotonic heuristics
- Two non-monotonic heuristics
Here are some hints and tips to help you with your implementation:
- Place your code in a file called
Searching.py.
- Do not modify any of the code I have provided, except for
MazeTest.py. For that program, I encourage you to add additional unit tests. Here are the return values for a search:
-
path should be a list of locations.
-
purged should be the number of nodes removed from the queue and found to be redundant.
-
proc should be the number of nodes removed from the queue and not purged.
-
gen should be the number of nodes added to the queue.
- Use the classes from the
Queue module for
both a FIFO queue and a priority queue.
- For your search algorithms, you will need to create a class to represent
a search node. Each object will need to represent:
- The current state (an object of the
State class).
- The operator that generated that state. For this task, a tuple representing the move made should suffice.
- The node that generated it.
- The sum of the node depth (g(n)) and estimated distance to the goal node (h'(n)).
- I highly recommend that, for your search node class, that you inherit
from
Mixins.Comparable. If you then override the __lt__ method to compare their respective heuristic estimates, you should be able to place them into a PriorityQueue without a hitch.
Proofs
- Prove that the Manhattan-distance heuristic is monotonic.
- Prove that your two additional heuristics are monotonic.
- Prove that your two non-monotonic heuristics are non-monotonic.
Experiments
For each heuristic, determine
experimentally the "hardest" mazes that it can solve in two minutes or less
using the Linux machines in the lab. If you would rather use your own
computer, be sure to specify its clock speed. You will need to determine the
"hardness" of mazes in the following categories:
- Perfect (no loops) to imperfect (very few barriers)
- Amount of treasure to be collected
- Size of the maze
For each experiment you run, record the values for each of the above
parameters, as well as the number of nodes expanded, maximum depth
reached, and effective branching factor for each heuristic. If the
heuristic takes longer than two minutes, feel free to terminate it and
record that, for that experiment, the heuristic took too long.
Paper
When you are finished with your experiments, you will write a short paper
summarizing your findings. Include the following details in your paper:
- A description of each heuristic, and a proof of its montonicity
(or lack thereof)
- The data you collected from each of your experiments
- An analysis of the data, including:
- A discussion of the relative merits of the heuristics relative to
breadth-first search and each other, and
- A discussion as to how varying the size, treasure, and perfection
affects the general difficulty of solving a maze by computer
- Discuss the degree to which the results matched your expectations
- Printouts of the code for your heuristics
Submit your code as well as your paper using
Sauron.
Grading criteria
| Grade | Content |
| A | Program is working with all heuristics Paper is complete Analysis properly characterizes the basis of each claim |
| B | One or two heuristics have small bugs The analysis is somewhat flawed |
| C | Problematic bugs and/or somewhat incomplete or moderately flawed paper |
| D | Severe bugs and/or multiple parts missing from paper |
| F | Program does not work at all and/or paper is not seriously attempted |