Hacker News new | ask | show | jobs
by ichinaski 4414 days ago
> # If we just got to the goal node, build and return the path.

  if adjacent == goal_node: 
    return build_path(goal_node)
If you want to ensure the path is optimal, you'll have to wait until you 'expand' the goal node, as there might exist goal states in the open set with lower costs.
1 comments

Fixed. It's a copy-paste artifact from Part I, where the algorithm is looking for a path, not the optimal path, so it didn't matter. Thanks!