SebastianLague

A* Pathfinding Tutorial 01 (Pseudocode)

Dec 19th, 2014
2,977
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.60 KB | None | 0 0
  1. OPEN //the set of nodes to be evaluated
  2. CLOSED //the set of nodes already evaluated
  3. add the start node to OPEN
  4.  
  5. loop
  6. current = node in OPEN with the lowest f_cost
  7. remove current from OPEN
  8. add current to CLOSED
  9.  
  10. if current is the target node //path has been found
  11. return
  12.  
  13. foreach neighbour of the current node
  14. if neighbour is not traversable or neighbour is in CLOSED
  15. skip to the next neighbour
  16.  
  17. if new path to neighbour is shorter OR neighbour is not in OPEN
  18. set f_cost of neighbour
  19. set parent of neighbour to current
  20. if neighbour is not in OPEN
  21. add neighbour to OPEN
Advertisement
Add Comment
Please, Sign In to add comment