[]Struct rltk::DijkstraMap

pub struct DijkstraMap {
    pub map: Vec<f32>,
    // some fields omitted
}

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>

Methods

impl DijkstraMap

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.

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.

pub fn clear(dm: &mut DijkstraMap)

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

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

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

Auto Trait Implementations

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.

impl<V, T> VZip<V> for T where
    V: MultiLane<T>,