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
impl Config
sourcepub(crate) fn auto_search_order(&self) -> Cow<'_, SearchOrder>
pub(crate) fn auto_search_order(&self) -> Cow<'_, SearchOrder>
Automatically determines the search order if search_order
is None
.
sourcepub(crate) fn search_order_iter(
&self,
search_order: &SearchOrder
) -> impl Iterator<Item = Coord>
pub(crate) fn search_order_iter( &self, search_order: &SearchOrder ) -> impl Iterator<Item = Coord>
Generates an iterator over cells coordinates from the search order.
sourcepub(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>>
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
impl Config
sourcepub fn new(width: i32, height: i32, period: i32) -> Self
pub fn new(width: i32, height: i32, period: i32) -> Self
Sets up a new configuration with given size.
sourcepub const fn set_translate(self, dx: i32, dy: i32) -> Self
pub const fn set_translate(self, dx: i32, dy: i32) -> Self
Sets the translations (dx, dy)
.
sourcepub const fn set_transform(self, transform: Transform) -> Self
pub const fn set_transform(self, transform: Transform) -> Self
Sets the transformation.
sourcepub const fn set_symmetry(self, symmetry: Symmetry) -> Self
pub const fn set_symmetry(self, symmetry: Symmetry) -> Self
Sets the symmetry.
sourcepub fn set_search_order<T: Into<Option<SearchOrder>>>(
self,
search_order: T
) -> Self
pub fn set_search_order<T: Into<Option<SearchOrder>>>( self, search_order: T ) -> Self
Sets the search order.
sourcepub const fn set_new_state(self, new_state: NewState) -> Self
pub const fn set_new_state(self, new_state: NewState) -> Self
Sets how to choose a state for an unknown cell.
sourcepub fn set_max_cell_count<T: Into<Option<u32>>>(self, max_cell_count: T) -> Self
pub fn set_max_cell_count<T: Into<Option<u32>>>(self, max_cell_count: T) -> Self
Sets the maximal number of living cells.
sourcepub const fn set_reduce_max(self, reduce_max: bool) -> Self
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.
sourcepub fn set_rule_string<S: ToString>(self, rule_string: S) -> Self
pub fn set_rule_string<S: ToString>(self, rule_string: S) -> Self
Sets the rule string.
sourcepub fn set_diagonal_width<T: Into<Option<i32>>>(self, diagonal_width: T) -> Self
pub fn set_diagonal_width<T: Into<Option<i32>>>(self, diagonal_width: T) -> Self
Sets the diagonal width.
sourcepub const fn set_skip_subperiod(self, skip_subperiod: bool) -> Self
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.
sourcepub const fn set_skip_subsymmetry(self, skip_subsymmetry: bool) -> Self
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.
sourcepub fn set_known_cells<T: Into<Vec<KnownCell>>>(self, known_cells: T) -> Self
pub fn set_known_cells<T: Into<Vec<KnownCell>>>(self, known_cells: T) -> Self
Sets cells whose states are known before the search.
sourcepub 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.
pub fn set_known_cells_from_rles<I, L>(self, input: I) -> Result<Self, RleError>where I: Input<Lines = L>, L: Input<Lines = L>,
read-rle
only.Sets cells whose states are known before the search.
The cells are specified by a list of RLE strings.
sourcepub const fn set_backjump(self, backjump: bool) -> Self
pub const fn set_backjump(self, backjump: bool) -> Self
Sets whether to enable backjumping.
sourcepub const fn require_square_world(&self) -> bool
pub const fn require_square_world(&self) -> bool
Whether the configuration requires the world to be square.
sourcepub const fn require_no_diagonal_width(&self) -> bool
pub const fn require_no_diagonal_width(&self) -> bool
Whether the configuration requires the world to have no diagonal width.
sourcepub(crate) fn contains(
&self,
(x, y, t): Coord,
including_border: bool,
check_diagonal_width: bool
) -> bool
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.