samples/13_path_finding_algorithms/05_dijkstra/app/main.rb
# This heat map shows the cells explored by the breadth first search and how far they are from the star.
This heat map shows the cells explored by the breadth first search and how far they are from the star.
This heat map shows the cells explored by the breadth first search and how far they are from the star .
def render_breadth_first_search_heat_map
    breadth_first_search.visited.each_key do | visited_cell |
      distance = (state.star.x - visited_cell.x).abs + (state.star.y - visited_cell.y).abs
      max_distance = grid.width + grid.height
      alpha = 255.to_i * distance.to_i / max_distance.to_i
      outputs.solids << [scale_up(visited_cell), red, alpha]
    end
  end
def render_breadth_first_search_heat_map breadth_first_search . visited . each_key do | visited_cell | distance = ( state . star . x - visited_cell . x ) . abs + ( state . star . y - visited_cell . y ) . abs max_distance = grid . width + grid . height alpha = 255 . to_i * distance . to_i / max_distance . to_i outputs . solids << [ scale_up ( visited_cell ) , red , alpha ] end end
This heat map shows the cells explored by the breadth first search and how far they are from the star.
This heat map shows the cells explored by the breadth first search and how far they are from the star .
# For each cell explored # Find its distance from the star # Get it as a percent of the maximum distance and scale to 255 for use as an alpha value