Recently I’ve found a nice piece of pseudo code for implementing A Star after searching through a few lesser or incorrect pseudo code passages:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38

clear open and closed let s be start node let e be end node s.loc = startloc s.g = 0 s.h = Cost( s, e ) push s to open while open not empty q = Pop lowest f in open if q == e traverse backpath of q.parent return success for each successor p g = q.g + GridCost( q, p ) if ( p is open or closed ) if ( p.g <= g ) continue p.parent = q p.g = g p.h = Cost( p, e ) p.f = g + p.h if ( p is closed ) p.closed = false if ( p is open ) resort open else push p to open return failure 
And here is the Pop function pseudo code (written by me, so it probably has a small error here or there):

find node with lowest f in open list remove node from open list add node to closed list return node 
My favorite thing about the pseudo code is Continue Reading →