我尝试用python实现A-star算法,但是当A完成代码并尝试使用最短路径函数时,没有输出也没有错误,有人能帮我找出原因吗? 这是我的法官代码,抱歉没有权利把所有代码放在这里:
# 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
这就是我的A星计划:
重复圆圈:
a)在字典边界中找到F的最小值,该点称为当前点
b)将当前点切换到当前点
c)对当前点相邻点的作用:
If the point is in the explored dictionary, skip over it.
If the point is in the frontier dictionary, add it into the dictionary and regard the current point as the father point of this point(put them into the Father_Son dictionary).
If the point is already in the frontier point, find the lowest value F, and put the key and value into the dictionary.
目前没有回答
相关问题 更多 >
编程相关推荐