Skip to main content

WfcConstrain

Trait WfcConstrain 

Source
pub trait WfcConstrain {
    type Offset;
    type Pattern: Eq + Hash + Clone;

    // Required methods
    fn all_patterns(&self) -> impl Iterator<Item = &Self::Pattern>;
    fn probability_of(&self, pattern: &Self::Pattern) -> f32;
    fn is_legal(
        &self,
        from: &Self::Pattern,
        offset: &Self::Offset,
        to: &Self::Pattern,
    ) -> bool;
}
Expand description

Trait for an object that specifies the rules by which wave function collapse tiles are chosen.

Required Associated Types§

Source

type Offset

The offset type that is used to specify the ways in which one pattern may be adjacent to another pattern.

Source

type Pattern: Eq + Hash + Clone

The type of patterns that wave function collapse will choose.

Required Methods§

Source

fn all_patterns(&self) -> impl Iterator<Item = &Self::Pattern>

Iterator for all the patterns that wave function collapse is allowed to choose. Note that any pattern with a probability of 0.0 must not be included.

Source

fn probability_of(&self, pattern: &Self::Pattern) -> f32

The probability of choosing a given pattern when there are no restrictions on patterns in any of the adjacent cells. This should be between 0.0 and 1.0.

True if the from pattern may be chosen when the to pattern has already been chosen for the cell at position offset relative to from.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§

Source§

impl<Pat, V> WfcConstrain for HashWfcConstraint<Pat, V>
where Pat: Eq + Hash + Clone + TilePattern,