PDA

نسخه کامل مشاهده نسخه کامل : توضیح چند خط کوچیک از یه شبهه کد



Akhavan
29-12-2009, 20:35
سلام.


این شبه کد مربوط به جستجوی A-star هست.
قسمتهایی را که با خط قرمز در مقابلشون مشخص کردم متوجه نمیشم کامل.
ممنون میشم کسی باشه که برای من شفافشون کنه.





functionA*(start,goal)



closedset := the emptyset% The set of nodes already evaluated.


openset := setcontaining the initial node% The set of tentative nodes to beevaluated.


g_score[start] := 0% Distance from start along optimal path.


h_score[start] := heuristic_estimate_of_distance(start, goal)


f_score[start] := h_score[start]% Estimated total distance from start to goal through y.


whileopensetisnot empty


x := thenode in openset having the lowest f_score[]value


ifx = goal


1 <----returnreconstruct_path(came_from,goal)


remove x from openset


addx to closedset


foreach y in neighbor_nodes(x)


ify in closedset


continue


----tentative_g_score := g_score[x] + dist_between(x,y)




----ify not in openset


----add y toopenset




----tentative_is_better := true


----elseiftentative_g_score < g_score[y]


----tentative_is_better := true


else


----tentative_is_better := false


----iftentative_is_better = true


came_from[y] := x


----g_score[y] := tentative_g_score


----h_score[y] := heuristic_estimate_of_distance(y, goal)


----f_score[y] := g_score[y] + h_score[y]


returnfailure




----functionreconstruct_path(came_from,current_node)


----ifcame_from[current_node]isset


----p = reconstruct_path(came_from,came_from[current_node])


----return(p + current_node)


else


returnthe emptypath



سپاسگذارم.{گل}

Akhavan
30-12-2009, 07:59
کسی نیست حتی شده یه خط این برنامه رو به من کمک کنه؟