Expert Systems
Expert Systems
We create two lists – Open List and Closed List (just like Dijkstra Algorithm)
g = The movement cost to move from the starting point to a given square on the
grid, following the path generated to get there.
h = The estimated movement cost to move from that given square on the grid to
the final destination.
OPEN – Nodes that have been generated and have had the heuristic function
applied to them but which have not yet been examined.
// A* Search Algorithm
1. Initialize the open list
2. Initialize the closed list
put the starting node on the OPEN list (you can leave its f at zero)
3. while the OPEN list is not empty
a) find the node with the least f on the open list, call it "q"
b) pop q off the OPEN list
c) generate q's successors and set their parents to q
d) for each successor
i) if successor is the goal, stop search
ii) else, compute both g and h for successor
successor.g = q.g + distance between successor and q
successor.h = distance from goal to successor
successor.f = successor.g + successor.h
iii) if a node with the same position as successor is in the OPEN list which
has a lower f than successor, skip this successor
iV) if a node with the same position as successor is in the CLOSED list
which has a lower f than successor, skip this successor otherwise, add the node to
the open list
end (for loop)