About

A* is a graph traversal and path searching algorithm that was developed in the 1960's. The algorithm is created in a best first search way, weighing the movement of traversal from the beginning node to the ending node following a f(n) = g(n) + h(n) formula; n being the next node. 'g' is the constant cost for movement in this example being used as 1 for 2-D and non diagonal traversal, but can be varied with diagonal and 3-D movement. 'h' is the heuristic function to create an approximate distance of the node's position to the end point, there are many different variations for the heuristic. 'f' is the final addition of the two that is used to determine the node with the lowest movement cost to find heirachy in a queue. For more information check out these links below:

Wiki  Geeks

    Pseudo-code
  • function pathfinder
  • // lists to be composed of nodes
  •  var openspotlist: [start]
  •  closedspotlist: []
  •  finalpath: []
  • while openspotlist has nodes
  • for nodes in openspotlist: select lowest f score
  • if (end of path)
  • // using parent for traceback
  •  while(parent)
  •  finalpath.push(parent
  •  return finalpath
  • openspotlist.slice(node)
  • for adjacent spaces of node
  •  if in(closedspotlist) || obstacle
  •  skip;
  •  if !alreadyVisited
  •  openspotlist.push(node)
  •  parent node = prev node
  •  f = g + h
  • return -1 //no path

For a visual presentation of how A* works, press the "Pathfind!" button below!