PointClickEngine::Navigation::HeuristicCalculator
Inherits Reference < Object
Heuristic calculation strategies for pathfinding algorithms
The HeuristicCalculator provides different distance calculation methods for use with pathfinding algorithms like A*. Different heuristics are suitable for different movement types and game requirements.
Constructors
for_movement(allow_diagonal : Bool, equal_costs : Bool = false) : HeuristicCalculator
Creates calculator with optimal settings for movement type
new(method : Method = Method::Octile, diagonal_cost : Float32 = PointClickEngine::Core::GameConstants::HEURISTIC_DIAGONAL_MULTIPLIER, orthogonal_cost : Float32 = 1.0_f32)
SourceClass methods
benchmark(iterations : Int32 = 10000) : Hash(Method, Float64)
Benchmarks different heuristic methods
optimal_method(allow_diagonal : Bool, equal_costs : Bool = false) : Method
Gets the ideal heuristic method for given movement constraints
Instance methods
calculate(from_x : Int32, from_y : Int32, to_x : Int32, to_y : Int32) : Float32
Calculates heuristic distance between grid coordinates
diagonal_cost
Sourcediagonal_cost=(diagonal_cost : Float32)
Sourceis_admissible?(allow_diagonal : Bool) : Bool
Validates if the heuristic is admissible (never overestimates)
method
Sourcemethod=(method : Method)
Sourcemovement_cost(from : Node, to : Node) : Float32
Gets the movement cost for traveling between two adjacent nodes
orthogonal_cost
Sourceorthogonal_cost=(orthogonal_cost : Float32)
Source