Class: Astar::Heuristic

Inherits:
Object
  • Object
show all
Defined in:
lib/astar/heuristic.rb

Direct Known Subclasses

EuclideanDistance, ManhattenDistance

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.score(node) ⇒ Object



3
4
5
# File 'lib/astar/heuristic.rb', line 3

def self.score(node)
  new(node).score
end

Instance Method Details

#relative_to_parentObject



7
8
9
10
11
12
13
# File 'lib/astar/heuristic.rb', line 7

def relative_to_parent
  return 10 if (@node.x > @node.parent.x && @node.y == @node.parent.y)
  return 10 if (@node.x < @node.parent.x && @node.y == @node.parent.y)
  return 10 if (@node.y > @node.parent.y && @node.x == @node.parent.x)
  return 10 if (@node.y < @node.parent.y && @node.x == @node.parent.x)
  14
end