samples/13_path_finding_algorithms/03_breadcrumbs/app/main.rb
# Finds the vertical and horizontal distance of a cell from the star
# and returns the larger value
# This method is used to have a zigzag pattern in the rendered path
# A cell that is [5, 5] from the star,
# is explored before over a cell that is [0, 7] away.
# So, if possible, the search tries to go diagonal (zigzag) first
Finds the vertical and horizontal distance of a cell from the star
and returns the larger value
This method is used to have a zigzag pattern in the rendered path
A cell that is [5, 5] from the star,
is explored before over a cell that is [0, 7] away.
So, if possible, the search tries to go diagonal (zigzag) first
Finds the vertical and horizontal distance of a cell from the star and returns the larger value This method is used to have a zigzag pattern in the rendered path A cell that is [ 5 5 ] from the star is explored before over a cell that is [ 0 7 ] away . So if possible the search tries to go diagonal ( zigzag ) first
def proximity_to_star(x, y)
    distance_x = (grid.star.x - x).abs
    distance_y = (grid.star.y - y).abs
    if distance_x > distance_y
      return distance_x
    else
      return distance_y
    end
  end
def proximity_to_star ( x , y ) distance_x = ( grid . star . x - x ) . abs distance_y = ( grid . star . y - y ) . abs if distance_x > distance_y return distance_x else return distance_y end end
Finds the vertical and horizontal distance of a cell from the star
and returns the larger value
This method is used to have a zigzag pattern in the rendered path
A cell that is [5, 5] from the star,
is explored before over a cell that is [0, 7] away.
Finds the vertical and horizontal distance of a cell from the star and returns the larger value This method is used to have a zigzag pattern in the rendered path A cell that is [ 5 5 ] from the star is explored before over a cell that is [ 0 7 ] away .
x
y