我尝试使用python来实现A-star算法,但是当完成代码并尝试使用shortest_path功能时,没有输出也没有错误,任何人都可以帮我找出原因吗? 这是我的判断代码,抱歉没有权利将所有代码放在这里:
<NavigationView Name="MyNavigationView">
...
<NavigationViewItemHeader Content="Themes" Visibility="{x:Bind MyNavigationView.IsPaneOpen, Mode=OneWay}"/>
...
<NavigationViewItemHeader Content="Builds" Visibility="{x:Bind MyNavigationView.IsPaneOpen, Mode=OneWay}"/>
...
</NavigationView>
这是我对A-star的整个计划:
重复圆圈:
a)在字典前沿中找到F的最小值,该点可以称为当前点
b)将当前点切换到已探索的词典
c)对当前点的相邻点的动作:
# When meet a point, judge what to do next, the point has a data structure of (name, distance to goal):
# map.intersections[start] is to find the coordinate of the start point in the map.
def judge(map, point_cur, point_near, point_target, dictionary_ep, dictionary_ft, dictionary_fs):
for i in dictionary_ep:
if point_near[0] != i:
for j in dictionary_ft:
if point_near[0] != j:
dictionary_ft[point_near[0]] = (point_cur[1] + distance(map.intersections[point_cur[0]], map.intersections[point_near[0]]) + distance(map.intersections[point_near[0]], map.intersections[point_target[0]]))
dictionary_fs[point_near[0]] = point_cur[0]
else:
if dictionary_ft[j] <= (point_cur[1] + distance(map.intersections[point_cur[0]], map.intersections[point_near[0]]) + distance(map.intersections[point_near[0]], map.intersections[point_target[0]])):
dictionary_fs[point_near[0]] = point_cur[0]
dictionary_ft[point_near[0]] = (point_cur[1] + distance(map.intersections[point_cur[0]], map.intersections[point_near[0]]) + distance(map.intersections[point_near[0]], map.intersections[point_target[0]]))
return 0