class

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

Source
for_platformer

Creates calculator for platformer games

Source
for_point_and_click

Creates calculator for specific game type

Source
for_strategy

Creates calculator for strategy games

Source
new(method : Method = Method::Octile, diagonal_cost : Float32 = PointClickEngine::Core::GameConstants::HEURISTIC_DIAGONAL_MULTIPLIER, orthogonal_cost : Float32 = 1.0_f32)
Source

Class methods

benchmark(iterations : Int32 = 10000) : Hash(Method, Float64)

Benchmarks different heuristic methods

Source
optimal_method(allow_diagonal : Bool, equal_costs : Bool = false) : Method

Gets the ideal heuristic method for given movement constraints

Source

Instance methods

calculate(from_x : Int32, from_y : Int32, to_x : Int32, to_y : Int32) : Float32

Calculates heuristic distance between grid coordinates

Source
calculate(from : Node, to : Node) : Float32

Calculates heuristic distance between two nodes

Source
diagonal_cost
Source
diagonal_cost=(diagonal_cost : Float32)
Source
is_admissible?(allow_diagonal : Bool) : Bool

Validates if the heuristic is admissible (never overestimates)

Source
method
Source
method=(method : Method)
Source
movement_cost(from : Node, to : Node) : Float32

Gets the movement cost for traveling between two adjacent nodes

Source
orthogonal_cost
Source
orthogonal_cost=(orthogonal_cost : Float32)
Source
to_s(io : IO) : Nil

String representation

Source

Nested types