我正在实现 A* 算法,但我被以下伪代码卡住了:
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
我想优化开放集检查,这样我就不会在一次算法通过中检查一个节点是否两次开放集。
我知道在 bash 中有类似的东西:
if(( false == openedList_.ContainsNodeXY(n.X, n.Y)) &&
InOpenSet = false ){ .... }
有了这个,我就会有关于节点是否在开放集中的信息。
我怎样才能在 C# 中做到这一点?
EDIT
openList_
是一个列表(我必须对其进行排序),所以它不能是一个HashSet
.