Reprint: Http://www.cppblog.com/mythit/archive/2009/04/19/80492.aspx
A * algorithm step:
1. Add the start grid to the open list.
2, repeat the following work:
A) Look for the grid with the lowest F value in the Open list. We call it the current lattice.
b) switch it to the off list.
c) to each of the adjacent lattices?
* If it is not available or is already in the close list, skip it. The reverse is as follows.
* If it is not in the open list, add it. Use the current grid as the parent node for this grid. Record the f,g, and H values for this grid.
* If it is already in the open list, it is better to check the new path with the G value for reference. A lower G-value means a better path. If so, change the parent node of the grid to the current grid and recalculate the G and F values of the grid. If you keep your open list sorted by F-value, you may need to re-order the open list after the change.
d) Stop, when you
* Add the target to the close list (note), when the path is found, or
* No target grid found, open list is empty. At this time, the path does not exist.
3. Save the path. Starting from the target, move along the parent node of each cell until you return to the start grid. This is your path.
A * Algorithm seeking path