我一直在阅读维基百科上的Astar 文章。在他们的实现中,他们检查每个节点是否在closed
集合中,如果是,则跳过它。如果启发式函数是可接受但不连续的,那么我们可能需要多次重新访问一个节点以改进它的f
值,这是否有可能呢?
以下是相关代码:
for each neighbor in neighbor_nodes(current)
if neighbor in closedset //This if condition bothers me
continue
tentative_g_score := g_score[current] + dist_between(current,neighbor)
if neighbor not in openset or tentative_g_score < g_score[neighbor]
came_from[neighbor] := current
g_score[neighbor] := tentative_g_score
f_score[neighbor] := g_score[neighbor] + heuristic_cost_estimate(neighbor, goal)
if neighbor not in openset
add neighbor to openset