Lab 4: Implementing A*

In this lab you will implement the A* algorithm for the domain in labs 2 and 3.

You will work in pairs on this lab (with provision for sections with an odd number of students). You can start with the lab 3 solution written by either student. It is expected that you will talk through the development together.

Implementing A*

Modify your Lab 3 solution by adding two methods to Rat:

    astar_path_to(self, target_location: Room) -> List[Room]
    """Returns the list of rooms from the start location to the
    target location, using A* search to find the path."""

    astar_directions_to(self, target_location: Room) -> List[str]
    """Return the list of room names from the rat's current location to
    the target location. Uses A* search."""

    rooms_visited_by_last_search(self) -> List[str]
    """Return the list of rooms visited (in any order)"""

As before, talk to your instructor if you do not have a working solution to lab 3; we will be happy to help you debug your lab 3 solution to where it can serve as a start for lab 4.

We did have to make a few more changes to existing files. Download the new versions:

Notes

Additional Notes

Submission

As for lab 3, submit your solution using esubmit. You will submit at least two files, your revised version of rat.py and the unchanged version of lab4_main.py. The other two files, the updated dungeon.py and test_lab4.py, are already provided by esubmit. If you do try to submit those two files, your version will be ignored.

Only ONE partner needs to submit. If both do submit at some point - reasonable when doing final debugging! - be sure the final submission is marked "OFFICIAL SUBMISSION" (in the comment block of rat.py) for just one of the two (and maybe submit an "IGNORE ME" submission for the other partner).

Note: it is likely you will have differences in your output compared to our output on this lab. In particular, the paths you compute for tests 6 and 7 are likely to be different than the paths we compute. This is because the order you visit equal-value rooms is not determined, so your solution is likely to explore slightly different rooms than ours. You may also visit a few rooms extra on test_rat_5. If you have any question about any differences in your output, contact your instructor.