samples/13_path_finding_algorithms/08_a_star/app/main.rb
def determine_input
    # If the mouse is over the star in the first grid
    if dijkstra_mouse_over_star?
      # The user is editing the star from the first grid
      state.user_input = :dijkstra_star
    # If the mouse is over the star in the second grid
    elsif greedy_mouse_over_star?
      # The user is editing the star from the second grid
      state.user_input = :greedy_star
    # If the mouse is over the star in the third grid
    elsif a_star_mouse_over_star?
      # The user is editing the star from the third grid
      state.user_input = :a_star_star
    # If the mouse is over the target in the first grid
    elsif dijkstra_mouse_over_target?
      # The user is editing the target from the first grid
      state.user_input = :dijkstra_target
    # If the mouse is over the target in the second grid
    elsif greedy_mouse_over_target?
      # The user is editing the target from the second grid
      state.user_input = :greedy_target
    # If the mouse is over the target in the third grid
    elsif a_star_mouse_over_target?
      # The user is editing the target from the third grid
      state.user_input = :a_star_target
    # If the mouse is over a wall in the first grid
    elsif dijkstra_mouse_over_wall?
      # The user is removing a wall from the first grid
      state.user_input = :dijkstra_remove_wall
    # If the mouse is over a wall in the second grid
    elsif greedy_mouse_over_wall?
      # The user is removing a wall from the second grid
      state.user_input = :greedy_remove_wall
    # If the mouse is over a wall in the third grid
    elsif a_star_mouse_over_wall?
      # The user is removing a wall from the third grid
      state.user_input = :a_star_remove_wall
    # If the mouse is over the first grid
    elsif dijkstra_mouse_over_grid?
      # The user is adding a wall from the first grid
      state.user_input = :dijkstra_add_wall
    # If the mouse is over the second grid
    elsif greedy_mouse_over_grid?
      # The user is adding a wall from the second grid
      state.user_input = :greedy_add_wall
    # If the mouse is over the third grid
    elsif a_star_mouse_over_grid?
      # The user is adding a wall from the third grid
      state.user_input = :a_star_add_wall
    end
  end
# Determines what the user is editing
# This method is called when the mouse is clicked down
Determines what the user is editing
This method is called when the mouse is clicked down
Determines what the user is editing This method is called when the mouse is clicked down
def determine_input
    if dijkstra_mouse_over_star?
      state.user_input = :dijkstra_star
    elsif greedy_mouse_over_star?
      state.user_input = :greedy_star
    elsif a_star_mouse_over_star?
      state.user_input = :a_star_star
    elsif dijkstra_mouse_over_target?
      state.user_input = :dijkstra_target
    elsif greedy_mouse_over_target?
      state.user_input = :greedy_target
    elsif a_star_mouse_over_target?
      state.user_input = :a_star_target
    elsif dijkstra_mouse_over_wall?
      state.user_input = :dijkstra_remove_wall
    elsif greedy_mouse_over_wall?
      state.user_input = :greedy_remove_wall
    elsif a_star_mouse_over_wall?
      state.user_input = :a_star_remove_wall
    elsif dijkstra_mouse_over_grid?
      state.user_input = :dijkstra_add_wall
    elsif greedy_mouse_over_grid?
      state.user_input = :greedy_add_wall
    elsif a_star_mouse_over_grid?
      state.user_input = :a_star_add_wall
    end
  end
def determine_input if dijkstra_mouse_over_star? state . user_input = :dijkstra_star elsif greedy_mouse_over_star? state . user_input = :greedy_star elsif a_star_mouse_over_star? state . user_input = :a_star_star elsif dijkstra_mouse_over_target? state . user_input = :dijkstra_target elsif greedy_mouse_over_target? state . user_input = :greedy_target elsif a_star_mouse_over_target? state . user_input = :a_star_target elsif dijkstra_mouse_over_wall? state . user_input = :dijkstra_remove_wall elsif greedy_mouse_over_wall? state . user_input = :greedy_remove_wall elsif a_star_mouse_over_wall? state . user_input = :a_star_remove_wall elsif dijkstra_mouse_over_grid? state . user_input = :dijkstra_add_wall elsif greedy_mouse_over_grid? state . user_input = :greedy_add_wall elsif a_star_mouse_over_grid? state . user_input = :a_star_add_wall end end
Determines what the user is editing
This method is called when the mouse is clicked down
Determines what the user is editing This method is called when the mouse is clicked down
# If the mouse is over the star in the first grid # The user is editing the star from the first grid # If the mouse is over the star in the second grid # The user is editing the star from the second grid # If the mouse is over the star in the third grid # The user is editing the star from the third grid # If the mouse is over the target in the first grid # The user is editing the target from the first grid # If the mouse is over the target in the second grid # The user is editing the target from the second grid # If the mouse is over the target in the third grid # The user is editing the target from the third grid # If the mouse is over a wall in the first grid # The user is removing a wall from the first grid # If the mouse is over a wall in the second grid # The user is removing a wall from the second grid # If the mouse is over a wall in the third grid # The user is removing a wall from the third grid # If the mouse is over the first grid # The user is adding a wall from the first grid # If the mouse is over the second grid # The user is adding a wall from the second grid # If the mouse is over the third grid # The user is adding a wall from the third grid