Advertisement
Guest User

Untitled

a guest
Jul 28th, 2015
147
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.08 KB | None | 0 0
  1. def A_star(h,c,dx,dy,u,s_id,e_id,Op,Cl,Prt,CC,o,ht,w):
  2. Op.append(s_id)
  3. while e_id not in Op :
  4. if Op == [ ] :
  5. break
  6. candidate = { }
  7. for i in Op :
  8. d = {i : CC[i]}
  9. candidate.update(d)
  10. o = min(candidate, key=candidate.get)
  11. Cl.append(o)
  12. Op.remove(o)
  13. adjacent_list = adjacent_cell(o,dx,dy )
  14. for p in adjacent_list :
  15. if p in Cl:
  16. adjacent_list = filter(lambda i: i != p, adjacent_list)
  17. elif p not in Op :
  18. Op.append(p)
  19. d = {p : o }
  20. Prt.update(d)
  21. d = {p : F(p,o,h,u,w,c,dx,e_id,ht,CC)}
  22. CC.update(d)
  23. elif id in Op :
  24. f1 = F(p,o,h,u,w,c,dx,e_id,ht,CC)
  25. f2 = F(p,Prt[p],h,u,w,c,dx,e_id,ht,CC)
  26. if f1 < f2 :
  27. d = {p : o }
  28. Prt.update(d)
  29. d = {id : F(p,o,h,u,w,c,dx,e_id,ht,CC)}
  30. CC.update(d)
  31. return Prt
  32.  
  33. while e_id not in Op :
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement