我有一个关于迷宫探路者的问题。我有一个深度优先的解决方案,但我想要一个广度优先的解决方案。 这是深度优先:
def find_path(pathList):
if pathList[-1] == goal:
return pathList
for i in adjacent_passages(labyrinth, pathList[-1]):
if i not in pathList:
found_path = find_path(pathList + [i])
if found_path:
return found_path
这就是我在广度优先问题上取得的“进展”:
^{pr2}$迷宫是迷宫的矩阵,相邻的通道找到相邻的正方形:)
目前没有回答
相关问题 更多 >
编程相关推荐