Struct hierarchical_pathfinding::prelude::PathCacheConfig[][src]

pub struct PathCacheConfig {
    pub chunk_size: usize,
    pub cache_paths: bool,
    pub a_star_fallback: bool,
    pub perfect_paths: bool,
}
Expand description

Options for configuring the PathCache

Default options:

assert_eq!(
    PathCacheConfig {
        chunk_size: 8,
        cache_paths: true,
        a_star_fallback: true,
        perfect_paths: false,
    },
    Default::default()
);

Fields

chunk_size: usize
Expand description

The size of the individual Chunks (defaults to 8)

tl;dr: Depends highly on the size of your Grid and Lengths of your Paths; requires Experimentation if you care.

Rough guide: Scale with a bigger Grid and longer desired Paths. (don’t quote me on this)

This has many different effects on the Performance and Memory:

smaller chunks make calculations within a Chunk faster

  • => decreased update time in tiles_changed
  • => decreased time to find start and end Nodes

bigger chunks lead to fewer Chunks and Nodes

  • => decreased time of actual search (especially for unreachable goals)
  • => longer Paths can be found a lot faster
Use CaseRecommendation
Frequent UpdatesSmaller Chunks
Longer Paths requiredLarger Chunks
Larger GridLarger Chunks
“No Path found” is commonLarger Chunks
Grid consists of small, windy corridorsSmaller Chunks
cache_paths: bool
Expand description

true (default): store the Paths inside each Chunk.

false: only store the Cost of the Path.

If set to false, calculating the full Path between two Points takes significantly more time. See AbstractPath for more details.

a_star_fallback: bool
Expand description

true (default): When a Path is short (roughly Length < 2 * chunk_size), a regular A* search is performed on the Grid after HPA* calculated a Path to confirm the existence and length.

false: The Paths are left as they are.

Setting this option to false will improve performance a bit, but the Paths will take seemingly random detours that makes them longer than they should be.

perfect_paths: bool
Expand description

true: Nodes are placed on every open entrance of a Chunk. This means that the resulting Paths are always the most optimal ones, but both Memory Usage and Performance are worse.

false (default): Nodes are placed on only some chunk entrances.

The exact effect depends greatly on the Grid and how the Chunks and their entrances align.

Implementations

impl PathCacheConfig[src]

pub const LOW_MEM: PathCacheConfig[src]

an example PathCacheConfig with options set to reduce Memory Usage

Values:

assert_eq!(
    PathCacheConfig {
        chunk_size: 32,
        cache_paths: false,
        a_star_fallback: true,
        perfect_paths: false,
    },
    PathCacheConfig::LOW_MEM
);

pub const HIGH_PERFORMANCE: PathCacheConfig[src]

an example PathCacheConfig with options set to improve Performance

Values:

assert_eq!(
    PathCacheConfig {
        chunk_size: 8,
        cache_paths: true,
        a_star_fallback: false,
        perfect_paths: false,
    },
    PathCacheConfig::HIGH_PERFORMANCE
);

Trait Implementations

impl Clone for PathCacheConfig[src]

fn clone(&self) -> PathCacheConfig[src]

Returns a copy of the value. Read more

fn clone_from(&mut self, source: &Self)1.0.0[src]

Performs copy-assignment from source. Read more

impl Debug for PathCacheConfig[src]

fn fmt(&self, f: &mut Formatter<'_>) -> Result[src]

Formats the value using the given formatter. Read more

impl Default for PathCacheConfig[src]

fn default() -> PathCacheConfig[src]

Returns the “default value” for a type. Read more

impl PartialEq<PathCacheConfig> for PathCacheConfig[src]

fn eq(&self, other: &PathCacheConfig) -> bool[src]

This method tests for self and other values to be equal, and is used by ==. Read more

fn ne(&self, other: &PathCacheConfig) -> bool[src]

This method tests for !=.

impl Copy for PathCacheConfig[src]

impl StructuralPartialEq for PathCacheConfig[src]

Auto Trait Implementations

Blanket Implementations

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

pub fn type_id(&self) -> TypeId[src]

Gets the TypeId of self. Read more

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

pub fn borrow(&self) -> &T[src]

Immutably borrows from an owned value. Read more

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

pub fn borrow_mut(&mut self) -> &mut T[src]

Mutably borrows from an owned value. Read more

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

pub fn from(t: T) -> T[src]

Performs the conversion.

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

pub fn into(self) -> U[src]

Performs the conversion.

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

pub fn to_owned(&self) -> T[src]

Creates owned data from borrowed data, usually by cloning. Read more

pub fn clone_into(&self, target: &mut T)[src]

🔬 This is a nightly-only experimental API. (toowned_clone_into)

recently added

Uses borrowed data to replace owned data, usually by cloning. Read more

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.

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

Performs the conversion.

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.

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

Performs the conversion.