Struct controlled_astar::astar::AStar
source · pub struct AStar { /* private fields */ }
Expand description
Structure implementing the A* algorithm.
Implementations§
source§impl AStar
impl AStar
sourcepub fn find_shortest_path(
&mut self,
start: (usize, usize),
goal: (usize, usize)
) -> Result<Option<Vec<(usize, usize)>>, AStarError>
pub fn find_shortest_path( &mut self, start: (usize, usize), goal: (usize, usize) ) -> Result<Option<Vec<(usize, usize)>>, AStarError>
Finds the shortest path from start to goal using the A* algorithm.
§Parameters
start
: The starting point as a tuple (x, y).goal
: The goal point as a tuple (x, y).
§Returns
A Result<Option<Vec<(usize, usize)>>, AStarError>
containing the path from the start to the goal if found,
or an AStarError
if no path is found or if an error occurs.
§Example
let mut astar = AStar::new(nodes);
let path = astar.find_shortest_path((0, 0), (5, 5));
Trait Implementations§
Auto Trait Implementations§
impl Freeze for AStar
impl RefUnwindSafe for AStar
impl Send for AStar
impl Sync for AStar
impl Unpin for AStar
impl UnwindSafe for AStar
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more