迷宫解决 - 运行时错误

Maze Solving - Runtime Error

在我的一些帮助下,我的 import_maze 功能开始工作后,我 运行 遇到了我的 maze_solving 功能的问题,经过 2 小时的试验后,我没有看到其他功能选择而不是再次寻求帮助。所以我的 maze_solving 函数抛出以下错误:

C:\Python34\python.exe C:/Users/Anton/PycharmProjects/BWINF_Aufgabe_1/Wegfinden.py
Traceback (most recent call last):
  File "C:/Users/Anton/PycharmProjects/BWINF_Aufgabe_1/Wegfinden.py", line 65, in <module>
    solved, solution = maze_solve(startx, starty, maze, solution)
        File "C:/Users/Anton/PycharmProjects/BWINF_Aufgabe_1/Wegfinden.py", line 44, in maze_solve
        solved, temp =  maze_solve(x-1, y, maze, solution)
      File "C:/Users/Anton/PycharmProjects/BWINF_Aufgabe_1/Wegfinden.py", line 34, in maze_solve
        solved, temp = maze_solve(x+1, y, maze, solution)
      File "C:/Users/Anton/PycharmProjects/BWINF_Aufgabe_1/Wegfinden.py", line 34, in maze_solve
        solved, temp = maze_solve(x+1, y, maze, solution)
      File "C:/Users/Anton/PycharmProjects/BWINF_Aufgabe_1/Wegfinden.py", line 27, in maze_solve
        if maze[x][y] == "#" or maze[x][y] == "*":
    RuntimeError: maximum recursion depth exceeded in comparison

    Process finished with exit code 1

我的代码:http://hastebin.com/owugupicaz.py

迷宫:

6 9
#########
#  #    #
#  # #  #
#  K #  #
#    #  #
#########

您陷入了无限递归,因为您正在处理已被标记为潜在路径的路径。这是因为您没有在重复之前标记您的路径。不要在检查中标记路径以解决问题,而是将 maze[x][y]="*" 放在递归和解决方案检查之外。如果将坏路径设置为 " ",那么自然只有好的路径会保持标记为