class

PointClickEngine::Navigation::AStarAlgorithm

Inherits Reference < Object

A* pathfinding algorithm implementation

The AStarAlgorithm class provides a pure implementation of the A* pathfinding algorithm. It uses a heuristic function to efficiently find optimal paths through a navigation grid while supporting various movement constraints.

Constructors

for_grid_based(grid : NavigationGrid) : AStarAlgorithm
Source
for_point_and_click(grid : NavigationGrid) : AStarAlgorithm

Creates A* algorithm with optimal settings for different game types

Source
for_strategy(grid : NavigationGrid) : AStarAlgorithm
Source
new(grid : NavigationGrid, heuristic_calculator : HeuristicCalculator = HeuristicCalculator.for_point_and_click, movement_validator : MovementValidator = MovementValidator.for_point_and_click, max_search_nodes : Int32 = PointClickEngine::Core::GameConstants::MAX_PATHFINDING_SEARCH_NODES)
Source

Instance methods

estimate_path_cost(start_x : Float32, start_y : Float32, end_x : Float32, end_y : Float32) : Float32

Estimates the cost of a path without finding it

Source
find_partial_path(start_x : Float32, start_y : Float32, end_x : Float32, end_y : Float32, max_distance : Float32 = 100.0_f32) : Array(RL::Vector2) | Nil

Finds partial path when full path is not available

Source
find_path(start_x : Float32, start_y : Float32, end_x : Float32, end_y : Float32) : Array(RL::Vector2) | Nil

Finds a path using A* algorithm

Source
find_path_grid(start_x : Int32, start_y : Int32, end_x : Int32, end_y : Int32) : Array(Node) | Nil

Finds path between grid coordinates

Source
get_search_stats

Gets search statistics from last pathfinding operation

Source
grid
Source
grid=(grid : NavigationGrid)
Source
heuristic_calculator
Source
heuristic_calculator=(heuristic_calculator : HeuristicCalculator)
Source
last_nodes_searched

Algorithm state for debugging

Source
last_nodes_searched=(last_nodes_searched : Int32)

Algorithm state for debugging

Source
last_search_time
Source
last_search_time=(last_search_time : Float64)
Source
max_search_nodes
Source
max_search_nodes=(max_search_nodes : Int32)
Source
movement_validator
Source
movement_validator=(movement_validator : MovementValidator)
Source
path_exists?(start_x : Float32, start_y : Float32, end_x : Float32, end_y : Float32) : Bool

Checks if a path exists without returning the full path

Source
to_s(io : IO) : Nil

String representation

Source
validate_configuration

Validates algorithm configuration

Source