def test_example_maze_from_instructions(self, example_maze):
        maze = Maze(num_rows=example_maze[0],
                    num_columns=example_maze[1],
                    cell_values=example_maze[2])
        maze.solve()

        assert maze.best_path == ['up', 'up', 'left']
示例#2
0
def maze_solver(filepath: str) -> None:
    mazes = read_file(filepath=filepath)
    for index, item in enumerate(mazes, start=1):
        num_rows, num_columns, cell_values = item
        logging.debug('*' * 50)
        logging.debug(f'Processing maze: {index}')
        logging.debug('*' * 50)

        maze = Maze(num_rows=num_rows, num_columns=num_columns, cell_values=cell_values)
        maze.solve()

        logging.debug(f'Start position: {maze.start_position}')
        logging.debug(f'End position: {maze.end_position}')
        logging.debug(f'Mines located at: {maze.mines}')

        print(maze.best_path)