Struct rlifesrc_lib::Config

source ·
pub struct Config {
Show 17 fields pub width: i32, pub height: i32, pub period: i32, pub dx: i32, pub dy: i32, pub transform: Transform, pub symmetry: Symmetry, pub search_order: Option<SearchOrder>, pub new_state: NewState, pub max_cell_count: Option<u32>, pub reduce_max: bool, pub rule_string: String, pub diagonal_width: Option<i32>, pub skip_subperiod: bool, pub skip_subsymmetry: bool, pub known_cells: Vec<KnownCell>, pub backjump: bool,
}
Expand description

World configuration.

The world will be generated from this configuration.

Fields§

§width: i32

Width.

§height: i32

Height.

§period: i32

Period.

§dx: i32

Horizontal translation.

§dy: i32

Vertical translation.

§transform: Transform

Transformations (rotations and reflections) after the last generation in a period.

After the last generation in a period, the pattern will return to the first generation, applying this transformation first, and then the translation defined by dx and dy.

§symmetry: Symmetry

Symmetries of the pattern.

§search_order: Option<SearchOrder>

The order to find a new unknown cell.

It will always search all generations of one cell before going to another cell.

None means that it will automatically choose a search order according to the width and height of the world.

§new_state: NewState

How to choose a state for an unknown cell.

§max_cell_count: Option<u32>

The number of minimum living cells in all generations must not exceed this number.

None means that there is no limit for the cell count.

§reduce_max: bool

Whether to automatically reduce the max_cell_count when a result is found.

The max_cell_count will be set to the cell count of the current result minus one.

§rule_string: String

The rule string of the cellular automaton.

§diagonal_width: Option<i32>

Diagonal width.

If the diagonal width is n, the cells at position (x, y) where abs(x - y) >= n are assumed to be dead.

§skip_subperiod: bool

Whether to skip patterns whose fundamental period are smaller than the given period.

§skip_subsymmetry: bool

Whether to skip patterns which are invariant under more transformations than required by the given symmetry.

In another word, whether to skip patterns whose symmetry group properly contains the given symmetry group.

§known_cells: Vec<KnownCell>

Cells whose states are known before the search.

§backjump: bool

(Experimental) Whether to enable backjumping.

Backjumping will reduce the number of steps, but each step will takes a much longer time. The current implementation is slower for most search, only useful for large (e.g., 64x64) still lifes.

Currently it is only supported for non-Generations rules. Generations rules will ignore this option.

Implementations§

source§

impl Config

source

pub(crate) const fn translate(&self, coord: Coord) -> Coord

Applies the transformation and translation to a coord.

source§

impl Config

source

pub(crate) fn auto_search_order(&self) -> Cow<'_, SearchOrder>

Automatically determines the search order if search_order is None.

source

pub(crate) fn search_order_iter( &self, search_order: &SearchOrder ) -> impl Iterator<Item = Coord>

Generates an iterator over cells coordinates from the search order.

source

pub(crate) fn fn_is_front( &self, rule_is_b0: bool, rule_gen: usize, rule_symmetry: Symmetry, search_order: &SearchOrder ) -> Option<Box<dyn Fn(Coord) -> bool>>

Generates a closure to determine whether a cell is in the front.

Return None when we should not force the front to be nonempty, or there isn’t a well-defined ‘front’.

source§

impl Config

source

pub fn new(width: i32, height: i32, period: i32) -> Self

Sets up a new configuration with given size.

source

pub const fn set_translate(self, dx: i32, dy: i32) -> Self

Sets the translations (dx, dy).

source

pub const fn set_transform(self, transform: Transform) -> Self

Sets the transformation.

source

pub const fn set_symmetry(self, symmetry: Symmetry) -> Self

Sets the symmetry.

source

pub fn set_search_order<T: Into<Option<SearchOrder>>>( self, search_order: T ) -> Self

Sets the search order.

source

pub const fn set_new_state(self, new_state: NewState) -> Self

Sets how to choose a state for an unknown cell.

source

pub fn set_max_cell_count<T: Into<Option<u32>>>(self, max_cell_count: T) -> Self

Sets the maximal number of living cells.

source

pub const fn set_reduce_max(self, reduce_max: bool) -> Self

Sets whether to automatically reduce the max_cell_count when a result is found.

source

pub fn set_rule_string<S: ToString>(self, rule_string: S) -> Self

Sets the rule string.

source

pub fn set_diagonal_width<T: Into<Option<i32>>>(self, diagonal_width: T) -> Self

Sets the diagonal width.

source

pub const fn set_skip_subperiod(self, skip_subperiod: bool) -> Self

Sets whether to skip patterns whose fundamental period is smaller than the given period.

source

pub const fn set_skip_subsymmetry(self, skip_subsymmetry: bool) -> Self

Sets whether to skip patterns which are invariant under more transformations than required by the given symmetry.

source

pub fn set_known_cells<T: Into<Vec<KnownCell>>>(self, known_cells: T) -> Self

Sets cells whose states are known before the search.

source

pub fn set_known_cells_from_rles<I, L>(self, input: I) -> Result<Self, RleError>where I: Input<Lines = L>, L: Input<Lines = L>,

Available on crate feature read-rle only.

Sets cells whose states are known before the search.

The cells are specified by a list of RLE strings.

source

pub const fn set_backjump(self, backjump: bool) -> Self

Sets whether to enable backjumping.

source

pub const fn require_square_world(&self) -> bool

Whether the configuration requires the world to be square.

source

pub const fn require_no_diagonal_width(&self) -> bool

Whether the configuration requires the world to have no diagonal width.

source

pub(crate) fn contains( &self, (x, y, t): Coord, including_border: bool, check_diagonal_width: bool ) -> bool

Whether the cell is contained in the world.

If including_border is true, this includes the cells at the border.

If check_diagonal_width is true, this excludes the cells outside of the diagonal_width.

source

pub fn world(&self) -> Result<PolyWorld, Error>

Creates a new world from the configuration. Returns an error if the rule string is invalid.

Trait Implementations§

source§

impl Clone for Config

source§

fn clone(&self) -> Config

Returns a copy of the value. Read more
1.0.0 · source§

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

Performs copy-assignment from source. Read more
source§

impl Debug for Config

source§

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

Formats the value using the given formatter. Read more
source§

impl Default for Config

source§

fn default() -> Self

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

impl<'de> Deserialize<'de> for Configwhere Config: Default,

source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
source§

impl Hash for Config

source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · source§

fn hash_slice<H>(data: &[Self], state: &mut H)where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
source§

impl PartialEq for Config

source§

fn eq(&self, other: &Config) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl Serialize for Config

source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
source§

impl Eq for Config

source§

impl StructuralEq for Config

source§

impl StructuralPartialEq for Config

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. 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 Twhere 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 Twhere T: Clone,

§

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 Twhere U: Into<T>,

§

type Error = Infallible

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

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

Performs the conversion.
source§

impl<T, U> TryInto<U> for Twhere U: TryFrom<T>,

§

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.
source§

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

source§

fn vzip(self) -> V

source§

impl<T> DeserializeOwned for Twhere T: for<'de> Deserialize<'de>,