[−]Struct rltk::DijkstraMap
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>,
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>,
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>
dm: &DijkstraMap,
position: usize,
map: &dyn BaseMap
) -> Option<usize>
pub fn find_highest_exit(
dm: &DijkstraMap,
position: usize,
map: &dyn BaseMap
) -> Option<usize>
dm: &DijkstraMap,
position: usize,
map: &dyn BaseMap
) -> Option<usize>
Auto Trait Implementations
impl RefUnwindSafe for DijkstraMap
impl Send for DijkstraMap
impl Sync for DijkstraMap
impl Unpin for DijkstraMap
impl UnwindSafe for DijkstraMap
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
V: MultiLane<T>,