class Astrid::Heuristics::Manhattan

Public Class Methods

new(end_node, weight=1) click to toggle source
# File lib/astrid/heuristics/manhattan.rb, line 5
def initialize(end_node, weight=1)
  @end_x = end_node[:x]
  @end_y = end_node[:y]
  @weight = weight
end

Public Instance Methods

h(node, weight=@weight) click to toggle source
# File lib/astrid/heuristics/manhattan.rb, line 11
def h(node, weight=@weight)
  weight * ((node[:x] - @end_x).abs + (node[:y] - @end_y).abs)
end