Image from https://www.101computing.net/a-star-search-algorithm/
โ A* algorithm is a heuristic search algorithm which use f-value
Admissible
Manhattan distance
function Astar(S, G):
define Min-Heap OPEN
define Hash-Table CLOSE
OPEN.push(S, h(S))
while OPEN is not Empty:
node = OPEN.pop()
if node == G:
return Path(S, G), CLOSE[node].g
else:
for child in T(node):
g = CLOSE[node].g + cost(node, child)
f = g + h(child)
if child not in CLOSED:
OPEN.push(child, f)
CLOSE.append(child)
CLOSE[child].g = g
CLOSE[child].f = f
if child in CLOSED and child.f < CLOSE[child].f:
CLOSE[child].g = g
CLOSE[child].f = f
return -1