Skip to main content

CostMetric

Trait CostMetric 

Source
pub trait CostMetric: Debug {
    // Required method
    fn delta_cost(
        &self,
        from: (usize, usize),
        to: (usize, usize),
        periodic: bool,
        width: usize,
        height: usize,
        diagonal: bool,
    ) -> f64;
}
Expand description

Trait for cost metrics used in A* pathfinding on 2D grids.

Implementing this trait allows custom cost metrics to be plugged into the grid A* algorithm.

Required Methods§

Source

fn delta_cost( &self, from: (usize, usize), to: (usize, usize), periodic: bool, width: usize, height: usize, diagonal: bool, ) -> f64

Estimate the cost of traveling from from to to.

For heuristic use, this should be admissible (never overestimate).

Implementors§