Lab 3: Alternative Searching Algorithms

This lab will give you experience with breadth-first search and iterative deepening. You will use both algorithms to search a state space. The lab builds on lab 2; if you do not have a working solution to lab 2, talk to your instructor to help you debug your current solution. Assuming you have a start, we will give you considerable help on that debugging,

Note there are two new files for this lab; you will need to download them:

Modify your lab 2 solution by adding the following two methods to Rat:

    bfs_directions_to(self, target_location: Room) -> List[str]
    """Return the list of rooms names from the rat's current location to
    the target location. Uses breadth-first search."""

    bfs_path_to(self, target_location: Room) -> List[Room]
    """Returns the list of rooms from the start location to the
    target location. Uses breadth-first search to find the path."""

In theory it would be possible to write a method that both path_to and bfs_path_to call to avoid repeating much code. Do not attempt this; it will result in very complex logic. Instead, copy the code for path_to and change it as follows:

In addition, add the following two methods to Rat:

    id_directions_to(self, target_location: Room) -> List[str]
    """Return the list of rooms names from the rat's current location to
    the target location. Uses iterative deepening."""

    id_path_to(self, target_location: Room) -> List[Room]
    """Returns the list of rooms from the start location to the
    target location. Uses iterative deepening."""

Again, copy the code from path_to and modify it to support iterative deepening. Some hints:

Note dungeon.py includes a size method giving the number of rooms in the dungeon.

Additional Notes

Submission

Submit your solution using esubmit as lab3alt. You will submit at least two files, your revised version of rat.py and the unchanged version of lab3_main.py. The other two files, dungeon.py and test_dungeons_two.py, are already provided by esubmit and should not be submitted.