samples/13_path_finding_algorithms/04_early_exit/app/main.rb
# Representation of how far away visited cells are from the star
# Replaces the render_visited method
# Visually demonstrates the effectiveness of early exit for pathfinding
Representation of how far away visited cells are from the star
Replaces the render_visited method
Visually demonstrates the effectiveness of early exit for pathfinding
Representation of how far away visited cells are from the star Replaces the render_visited method Visually demonstrates the effectiveness of early exit for pathfinding
def render_heat_map
    state.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
    state.early_exit_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 << [early_exit_scale_up(visited_cell), red, alpha]
    end
  end
def render_heat_map state . 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 state . early_exit_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 << [ early_exit_scale_up ( visited_cell ) , red , alpha ] end end
Representation of how far away visited cells are from the star
Replaces the render_visited method
Visually demonstrates the effectiveness of early exit for pathfinding
Representation of how far away visited cells are from the star Replaces the render_visited method Visually demonstrates the effectiveness of early exit for pathfinding
# outputs.solids << [early_exit_scale_up(visited_cell), red, alpha]