Last active
September 22, 2022 16:44
-
-
Save kartikkukreja/ddc476395e7d7511486d to your computer and use it in GitHub Desktop.
A* Tree Search Pseudocode
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def A*-TREE-SEARCH (start): | |
Let pq be an empty min priority queue | |
g(start) = 0 | |
f(start) = h(start) | |
path(start) = [] | |
pq.push(start, f(start)) | |
while not pq.empty(): | |
top = pq.pop() | |
if isGoal(top): | |
return f(top), path(top) | |
foreach next in succ(top): | |
g(next) = g(top) + cost(top, next) | |
f(next) = g(next) + h(next) | |
path(next) = path(top).append(next) | |
pq.push(next, f(next)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment