samples/13_path_finding_algorithms/07_heuristic_with_walls/app/main.rb
# Calculates the path between the target and star for the heuristic search
# Only called when the heuristic search finds the target
Calculates the path between the target and star for the heuristic search
Only called when the heuristic search finds the target
Calculates the path between the target and star for the heuristic search Only called when the heuristic search finds the target
def heuristic_calc_path
    endpoint = grid.target
    next_endpoint = heuristic.came_from[endpoint]
    while endpoint and next_endpoint
      path = get_path_between(endpoint, next_endpoint)
      heuristic.path << path
      endpoint = next_endpoint
      next_endpoint = heuristic.came_from[endpoint]
    end
  end
def heuristic_calc_path endpoint = grid . target next_endpoint = heuristic . came_from [ endpoint ] while endpoint and next_endpoint path = get_path_between ( endpoint , next_endpoint ) heuristic . path << path endpoint = next_endpoint next_endpoint = heuristic . came_from [ endpoint ] end end
Calculates the path between the target and star for the heuristic search
Only called when the heuristic search finds the target
Calculates the path between the target and star for the heuristic search Only called when the heuristic search finds the target
# Start from the target # And the cell it came from # Draw a path between these two cells and store it # And get the next pair of cells # Continue till there are no more cells