Professional Documents
Culture Documents
AO Star
AO Star
if node in solution_path:
return h(node), solution_path[node]
# Update the best cost and best child if the total cost is lower
if total_cost < best_cost:
best_cost = total_cost
best_child = children
# Update the solution path with the best child and its cost
solution_path[node] = (best_child, best_cost)
return best_cost, solution_path
def is_goal_node(node):
# Define your goal check here
return node == 'Goal'
# Example usage:
solution_path = {}
# Adjacency list of the graph
adjacency_list = {
'A': [('B', 1), ('C', 2)],
'B': [('D', 3), ('E', 4)],
'C': [('F', 5)],
'D': [('G', 6)],
'E': [('G', 4)],
'F': [('G', 3)],
'G': [] # Goal node has no children
}