pub struct GridPathfinder { /* private fields */ }Expand description
Weighted 2D grid pathfinder supporting A*, multi-goal Dijkstra, and Jump Point Search.
Implementations§
Source§impl GridPathfinder
Core operations for GridPathfinder including A*, multi-goal Dijkstra, and Jump Point Search.
impl GridPathfinder
Core operations for GridPathfinder including A*, multi-goal Dijkstra, and Jump Point Search.
Sourcepub fn is_walkable(&self, coord: GridCoord) -> bool
pub fn is_walkable(&self, coord: GridCoord) -> bool
Sourcepub fn set_cell_cost(&mut self, coord: GridCoord, cost: f32)
pub fn set_cell_cost(&mut self, coord: GridCoord, cost: f32)
Sets the traversal cost of coord (<= 0.0 marks the cell blocked).
§Arguments
GridCoord- Cell coordinate to update.f32- New traversal cost (<= 0.0or non-finite blocks the cell).
Sourcepub fn set_blocked(&mut self, coord: GridCoord, blocked: bool)
pub fn set_blocked(&mut self, coord: GridCoord, blocked: bool)
Marks coord blocked (blocked == true) or walkable with cost 1.0 (blocked == false).
§Arguments
GridCoord- Cell coordinate to update.bool- Whether the cell should be impassable.
Sourcepub fn find_path(
&mut self,
start: GridCoord,
goal: GridCoord,
connectivity: GridConnectivity,
algorithm: GridSearchAlgorithm,
) -> Option<GridPathResult>
pub fn find_path( &mut self, start: GridCoord, goal: GridCoord, connectivity: GridConnectivity, algorithm: GridSearchAlgorithm, ) -> Option<GridPathResult>
Finds an optimal shortest path using the selected algorithm and connectivity policy.
§Arguments
GridCoord- Start cell coordinate.GridCoord- Goal cell coordinate.GridConnectivity- 4-way or 8-way (no-corner-cutting) connectivity.GridSearchAlgorithm- Search strategy (AStar,Dijkstra, orJumpPointSearch).
§Returns
Option<GridPathResult>- Optimal path and cost if reachable.
Sourcepub fn find_path_astar(
&mut self,
start: GridCoord,
goal: GridCoord,
connectivity: GridConnectivity,
) -> Option<GridPathResult>
pub fn find_path_astar( &mut self, start: GridCoord, goal: GridCoord, connectivity: GridConnectivity, ) -> Option<GridPathResult>
Finds an optimal shortest path using A* with admissible Manhattan or Octile heuristics.
§Arguments
GridCoord- Start cell coordinate.GridCoord- Goal cell coordinate.GridConnectivity- 4-way or 8-way (no-corner-cutting) connectivity.
§Returns
Option<GridPathResult>- Optimal path and total cost if reachable.
Sourcepub fn find_path_astar_into(
&mut self,
start: GridCoord,
goal: GridCoord,
connectivity: GridConnectivity,
out_path: &mut Vec<GridCoord>,
) -> Option<f32>
pub fn find_path_astar_into( &mut self, start: GridCoord, goal: GridCoord, connectivity: GridConnectivity, out_path: &mut Vec<GridCoord>, ) -> Option<f32>
Finds an optimal shortest path using A* while writing waypoints into a caller-owned buffer.
§Arguments
GridCoord- Start cell coordinate.GridCoord- Goal cell coordinate.GridConnectivity- 4-way or 8-way connectivity.&mut Vec<GridCoord>- Reusable output path buffer.
§Returns
Option<f32>- Optimal total path cost when reachable.
Sourcepub fn find_path_dijkstra(
&mut self,
start: GridCoord,
goal: GridCoord,
connectivity: GridConnectivity,
) -> Option<GridPathResult>
pub fn find_path_dijkstra( &mut self, start: GridCoord, goal: GridCoord, connectivity: GridConnectivity, ) -> Option<GridPathResult>
Sourcepub fn find_path_dijkstra_multi_goal(
&mut self,
start: GridCoord,
goals: &[GridCoord],
connectivity: GridConnectivity,
) -> Option<GridPathResult>
pub fn find_path_dijkstra_multi_goal( &mut self, start: GridCoord, goals: &[GridCoord], connectivity: GridConnectivity, ) -> Option<GridPathResult>
Finds the optimal shortest path to the nearest reachable goal in goals using Dijkstra.
§Arguments
GridCoord- Start cell coordinate.&[GridCoord]- Candidate target goal cells.GridConnectivity- 4-way or 8-way (no-corner-cutting) connectivity.
§Returns
Option<GridPathResult>- Shortest path to whichever goal has minimum total cost.
Sourcepub fn find_path_jps(
&mut self,
start: GridCoord,
goal: GridCoord,
connectivity: GridConnectivity,
) -> Option<GridPathResult>
pub fn find_path_jps( &mut self, start: GridCoord, goal: GridCoord, connectivity: GridConnectivity, ) -> Option<GridPathResult>
Finds an optimal shortest path using Jump Point Search on uniform-cost grids (falling back to A* if weighted).
§Arguments
GridCoord- Start cell coordinate.GridCoord- Goal cell coordinate.GridConnectivity- 4-way or 8-way (no-corner-cutting) connectivity.
§Returns
Option<GridPathResult>- Optimal expanded cell-by-cell path with exact shortest cost.
Source§impl GridPathfinder
Implements impl #impl_generics #name #ty_generics #where_clause.
impl GridPathfinder
Implements impl #impl_generics #name #ty_generics #where_clause.