Class: Astrid::Heuristics::Manhattan
- Inherits:
-
Object
- Object
- Astrid::Heuristics::Manhattan
- Defined in:
- lib/astrid/heuristics/manhattan.rb
Instance Method Summary collapse
- #h(node, weight = @weight) ⇒ Object
-
#initialize(end_node, weight = 1) ⇒ Manhattan
constructor
A new instance of Manhattan.
Constructor Details
#initialize(end_node, weight = 1) ⇒ Manhattan
Returns a new instance of Manhattan.
5 6 7 8 9 |
# 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 |
Instance Method Details
#h(node, weight = @weight) ⇒ Object
11 12 13 |
# 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 |