[][src]Trait hierarchical_pathfinding::neighbors::Neighborhood

pub trait Neighborhood: Clone + Debug {
    fn get_all_neighbors(&self, point: Point) -> Box<dyn Iterator<Item = Point>>;
fn heuristic(&self, point: Point, goal: Point) -> usize; }

Defines how a Path can move along the Grid.

Different Scenarios may have different constraints as to how a Path may be formed. For example if Agents can only move along the 4 cardinal directions, any Paths generated should reflect that by only containing those steps.

This Trait is a generalized solution to that problem. It provides a function to query all neighboring Points of an existing Point and a Heuristic for how long it might take to reach a goal from a Point.

The most common implementations of this Trait are already provided by this Module:

Required methods

fn get_all_neighbors(&self, point: Point) -> Box<dyn Iterator<Item = Point>>

Provides a list of Neighbors of a Point

Note that it is not necessary to check weather the Tile at a Point is solid or not. That check is done later.

fn heuristic(&self, point: Point, goal: Point) -> usize

Gives a Heuristic for how long it takes to reach goal from point.

This is usually the Distance between the two Points in the Metric of your Neighborhood.

If there is no proper way of calculation how long it takes, simply return 0. This will increase the time it takes to calculate the Path, but at least it will always be correct.

Loading content...

Implementors

impl Neighborhood for ManhattanNeighborhood[src]

impl Neighborhood for MooreNeighborhood[src]

Loading content...