Struct DijkstraMap

Source
pub struct DijkstraMap {
    pub map: Vec<f32>,
    /* private fields */
}
Expand description

Representation of a Dijkstra flow map. map is a vector of floats, having a size equal to size_x * size_y (one per tile). size_x and size_y are stored for overflow avoidance. max_depth is the maximum number of iterations this search shall support.

Fields§

§map: Vec<f32>

Implementations§

Source§

impl DijkstraMap

Source

pub fn new<T>( size_x: T, size_y: T, starts: &[usize], map: &dyn BaseMap, max_depth: f32, ) -> DijkstraMap
where T: TryInto<usize>,

Construct a new Dijkstra map, ready to run. You must specify the map size, and link to an implementation of a BaseMap trait that can generate exits lists. It then builds the map, giving you a result.

Source

pub fn new_weighted<T>( size_x: T, size_y: T, starts: &[(usize, f32)], map: &dyn BaseMap, max_depth: f32, ) -> DijkstraMap
where T: TryInto<usize>,

Construct a new Dijkstra map, ready to run. You must specify the map size, and link to an implementation of a BaseMap trait that can generate exits lists. It then builds the map, giving you a result. Starts is provided as a set of tuples, two per tile. The first is the tile index, the second the starting weight (defaults to 0.0 on new)

Source

pub fn new_empty<T>(size_x: T, size_y: T, max_depth: f32) -> DijkstraMap
where T: TryInto<usize>,

Creates an empty Dijkstra map node.

Source

pub fn clear(dm: &mut DijkstraMap)

Source

pub fn build(dm: &mut DijkstraMap, starts: &[usize], map: &dyn BaseMap)

Builds the Dijkstra map: iterate from each starting point, to each exit provided by BaseMap’s exits implementation. Each step adds cost to the current depth, and is discarded if the new depth is further than the current depth. WARNING: Will give incorrect results when used with non-uniform exit costs. Much slower algorithm required to support that. Automatically branches to a parallel version if you provide more than 4 starting points

Source

pub fn build_weighted( dm: &mut DijkstraMap, starts: &[(usize, f32)], map: &dyn BaseMap, )

Builds the Dijkstra map: iterate from each starting point, to each exit provided by BaseMap’s exits implementation. Each step adds cost to the current depth, and is discarded if the new depth is further than the current depth. WARNING: Will give incorrect results when used with non-uniform exit costs. Much slower algorithm required to support that. Automatically branches to a parallel version if you provide more than 4 starting points

Source

pub fn find_lowest_exit( dm: &DijkstraMap, position: usize, map: &dyn BaseMap, ) -> Option<usize>

Source

pub fn find_highest_exit( dm: &DijkstraMap, position: usize, map: &dyn BaseMap, ) -> Option<usize>

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.