module Heuristic
A collection of heuristic functions.
Public Class Methods
chebyshev(dx, dy)
click to toggle source
Chebyshev distance.
# File lib/pathfinding/core/heuristic.rb, line 38 def self.chebyshev(dx, dy) [dx, dy].max end
euclidean(dx, dy)
click to toggle source
Euclidean distance.
# File lib/pathfinding/core/heuristic.rb, line 23 def self.euclidean(dx, dy) Math.sqrt(dx * dx + dy * dy) end
manhattan(dx, dy)
click to toggle source
Manhattan distance.
# File lib/pathfinding/core/heuristic.rb, line 16 def self.manhattan(dx, dy) dx + dy end
octile(dx, dy)
click to toggle source
Octile distance.
# File lib/pathfinding/core/heuristic.rb, line 30 def self.octile(dx, dy) f = Math.sqrt(2) - 1 dx < dy ? f * dx + dy : f * dy + dx end