Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def A_star(h,c,dx,dy,u,s_id,e_id,Op,Cl,Prt,CC,o,ht,w):
- Op.append(s_id)
- while e_id not in Op :
- if Op == [ ] :
- break
- candidate = { }
- for i in Op :
- d = {i : CC[i]}
- candidate.update(d)
- o = min(candidate, key=candidate.get)
- Cl.append(o)
- Op.remove(o)
- adjacent_list = adjacent_cell(o,dx,dy )
- for p in adjacent_list :
- if p in Cl:
- adjacent_list = filter(lambda i: i != p, adjacent_list)
- elif p not in Op :
- Op.append(p)
- d = {p : o }
- Prt.update(d)
- d = {p : F(p,o,h,u,w,c,dx,e_id,ht,CC)}
- CC.update(d)
- elif id in Op :
- f1 = F(p,o,h,u,w,c,dx,e_id,ht,CC)
- f2 = F(p,Prt[p],h,u,w,c,dx,e_id,ht,CC)
- if f1 < f2 :
- d = {p : o }
- Prt.update(d)
- d = {id : F(p,o,h,u,w,c,dx,e_id,ht,CC)}
- CC.update(d)
- return Prt
- while e_id not in Op :
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement