Skip to main content

a_star_weighted

Function a_star_weighted 

Source
pub fn a_star_weighted<T, G, H>(
    map: &Grid<T>,
    start: Point,
    goal: Point,
    move_set: MoveSet,
    edge_cost: G,
    heuristic: H,
    weight: HeuristicWeight,
) -> Option<Path>
where G: Fn(Point, Point) -> Option<Cost>, H: Fn(Point, Point) -> Cost,
Expand description

Returns a weighted A* path from start to goal using bounded movement.

HeuristicWeight::Static accepts 0.0..=2.0: 0.0 ignores the heuristic, 1.0 is standard A*, and larger values increasingly favor the heuristic over the known path cost. HeuristicWeight::Dynamic accepts 1.0..=2.0 and uses the pxWD weighting function.

§Parameters

  • map - The grid map to search.
  • start - The starting point.
  • goal - The goal point.
  • move_set - The set of allowed moves.
  • edge_cost - The cost function for edge traversal.
  • heuristic - The heuristic function for estimating the cost to the goal.
  • weight - The weight factor for the heuristic. See HeuristicWeight

Invalid weights and unreachable goals both return None; use a_star_weighted_with_topology when the invalid-weight error must be distinguished from an unreachable goal.

§Panics

Panics when start or goal is outside map.