def connect_neighbors(dungeon: Dungeon, row: int, col: int) -> None: """Connects the room at the given row, col to all neighbors""" current_room = dungeon.find(str(row) + "," + str(col)) if row != 0: room = dungeon.find(str(row - 1) + "," + str(col)) current_room.add_neighbor(room, Direction.NORTH) if col != 0: room = dungeon.find(str(row) + "," + str(col - 1)) current_room.add_neighbor(room, Direction.WEST)
def check_paths_are_similar(dungeon: Dungeon, computed_path: List[str], expected_path: List[str]) -> None: """Checks if computed path is valid and has the right length.""" rooms_in_path = [dungeon.find(r) for r in computed_path] if not dungeon.valid_path(rooms_in_path): print("Computed path, " + str(computed_path) + ", is not connected.") assert dungeon.valid_path(rooms_in_path) if len(computed_path) > len(expected_path): print("Computed path, " + str(computed_path) + ", is longer than expected path, " + str(expected_path)) assert len(computed_path) == len(expected_path) # should neve fail