Skip to content

Instantly share code, notes, and snippets.

@gfelber36
gfelber36 / A* Algorithm
Created March 12, 2012 19:08
Javascript Implementation of the A* Algorithm for Pathfinding
/*
Pathfinding using the A* Algorigthm: By Greg Felber
This function is used to determine the quickest path from a starting node to a target node via a connected
series of nodes.
The A* Algorithm begins by checking to see the visible waypoints of the starting node. These connected nodes
will be known as its neighbors. Each neighbors cost "F" will be calculated by summing the distance between
the starting node to the best point, "G", and the best point to the target node, "H". The neighbor with the lowest
cost is selected as the best node and added to the array of closed nodes and removed from the list of open nodes