Class: Astar::ManhattenDistance

Inherits:
Heuristic show all
Defined in:
lib/astar/heuristic/manhatten_distance.rb

Instance Method Summary collapse

Methods inherited from Heuristic

#relative_to_parent, score

Instance Method Details

#scoreObject



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

def score
  f = relative_to_parent
  g = (@node.destination.x - @node.x).abs + (@node.destination.y - @node.y).abs
  f + g
end