Skip to main content

WfcRuleSet

Struct WfcRuleSet 

Source
pub struct WfcRuleSet { /* private fields */ }
Expand description

Tile weights and four-way adjacency compatibility rules for WfcSolver2D.

Implementations§

Source§

impl WfcRuleSet

Rule-set construction and symmetric adjacency registration for WfcRuleSet.

Source

pub fn new(tile_count: usize) -> Self

Creates an empty WfcRuleSet for tile_count tiles (clamped to [1, 128]), all weighted 1.0.

§Arguments
  • usize - Number of tile types in 1..=128.
§Returns
  • Self - Rule set ready for adjacency registration.
Source

pub fn set_weight(&mut self, tile_index: usize, weight: f32)

Sets the relative selection weight for tile_index (clamped to >= 1e-4).

§Arguments
  • usize - Tile index.
  • f32 - Positive tile weight.
Source

pub fn allow_adjacency( &mut self, tile_a: usize, dir: WfcDirection, tile_b: usize, )

Allows tile_b to sit directly in direction dir from tile_a (and registers the symmetric opposite).

§Arguments
  • usize - Source tile index.
  • WfcDirection - Cardinal direction from tile_a to tile_b.
  • usize - Neighbor tile index.
Source

pub fn allow_all_directions(&mut self, tile_a: usize, tile_b: usize)

Allows tile_a and tile_b to sit adjacent in all four cardinal directions.

§Arguments
  • usize - First tile index.
  • usize - Second tile index.
Source

pub fn is_compatible( &self, tile_a: usize, dir: WfcDirection, tile_b: usize, ) -> bool

Returns whether tile_b is permitted immediately in direction dir from tile_a.

§Arguments
  • usize - Source tile index.
  • WfcDirection - Cardinal direction to neighbor.
  • usize - Neighbor tile index.
§Returns
  • bool - true if compatible.
Source§

impl WfcRuleSet

Implements impl #impl_generics #name #ty_generics #where_clause.

Source

pub fn get_tile_count(&self) -> usize

Source

pub fn get_mut_tile_count(&mut self) -> &mut usize

Source

pub fn set_tile_count(&mut self, val: usize) -> &mut Self

Source

pub fn get_weights(&self) -> &Vec<f32>

Source

pub fn get_mut_weights(&mut self) -> &mut Vec<f32>

Source

pub fn set_weights(&mut self, val: Vec<f32>) -> &mut Self

Trait Implementations§

Source§

impl Clone for WfcRuleSet

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for WfcRuleSet

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl Forget for WfcRuleSet

§

impl Freeze for WfcRuleSet
where *const u8 is !null: Freeze, PhantomData<f32>: Freeze, PhantomData<[WfcMask; 4]>: Freeze,

§

impl Move for WfcRuleSet

§

impl RefUnwindSafe for WfcRuleSet

§

impl Send for WfcRuleSet
where RawVecInner: Send,

§

impl Sync for WfcRuleSet
where RawVecInner: Sync,

§

impl Unpin for WfcRuleSet
where *const u8 is !null: Unpin,

§

impl UnsafeUnpin for WfcRuleSet

§

impl UnwindSafe for WfcRuleSet
where RawVecInner: UnwindSafe,

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

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

fn clone_into(&self, target: &mut T)

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

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

Source§

type Error = !

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

fn try_from(value: U) -> Result<T, !>

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.