finds a least-cost path from a given initial node to one goal node (out of one or more possible goals). As A* traverses the graph, it follows a path of the lowest known heuristic cost, keeping a sorted priority queue of alternate path segments along the way.
A, add the node to a “open list” of nodes to be considered. The “open list” is like a shop list, at this moment we just have only one node on our list. Basically is a list of the nodes that must be verified.
all reachable nodes, neighbors that are not walls, water or any other unreachable node. Add all of them to the “open list”, for each one of the nodes, save the previous node (in this case node A) as a father node. This reference will be crucial when we want ot make the trackback.
on the “open list” the node with the smaller value for F, where F = G + H Aditionally, G = cost to arrive until this point H = estimated cost to arrive on the goal, from the current node, called heuristic
to guess about something, you cannot assume that the heuristic is the best value, b but how you still don’t know how to arrive to the goal you have to guess if you are getting warmer or colder. In our case we are going use the sum of nodes on the horizontal and vertical directions from the current node to the goal. (Manhattan method)
all neighbors nodes, ignoring the ones that are on the “closed list” or are not reachable (walls, water, ...), add them to the “open list” if they are not already. Make sure to reference the father node to the new ones.
one of the neighbors nodes are on the “open list” you must check if the new path is shorter than the previous, if is greater, do nothing. But if is really shorter, you must update the value of G on this node and it father node, ignoring the previous path taken.
stop? There are 2 cases: The goal node was added to the “closed list”, this case, the path was found The “open list” does not have any more itens and the goal node was not found, this way you should stop and say that there are no possible path.
Dijkstra in 1956, is a graph search algorithm that solves the single-source shortest path problem for a graph, producing a shortest path tree. This algorithm is often used in routing and as a subroutine in other graph algorithms.
the A* algorithm the main difference is that we don’t have a heuristic for the calculation of the F. Additionally in the end of the process we will have ALL the minor distances between ALL the nodes of the graph.
a group of nodes with infinite weight to reach it, and zero for the starting point. Additionally we gonna set values on the connections between the nodes as a distance between them.
gonna take the starting node and add it to a “open list”. 2- We visit every single node reachable from the starting node, calculate the weight to arrive until that node, if is smaller than the actual value we “relax” it and set the father as the starting point. 3 – All visited nodes go to the “open list”. 4 – The starting node goes to the “closed list”