Trait rlifesrc_lib::rules::Rule
source · pub trait Rule: Sealed {
type Desc: Copy;
type IsGen: Bool;
// Required methods
fn has_b0(&self) -> bool;
fn has_b0_s8(&self) -> bool;
fn gen(&self) -> usize;
fn symmetry(&self) -> Symmetry;
fn new_desc(state: State, succ_state: State) -> Self::Desc;
fn update_desc(cell: &LifeCell<Self>, state: State, new: bool);
fn consistify<A: Algorithm<Self>>(
world: &mut World<Self, A>,
cell: CellRef<Self>
) -> Result<(), A::ConflReason>;
}
Expand description
Required Associated Types§
Required Methods§
sourcefn has_b0(&self) -> bool
fn has_b0(&self) -> bool
Whether the rule contains B0
.
In other words, whether a dead cell would become ALIVE
in the next
generation, if all its neighbors in this generation are dead.
sourcefn has_b0_s8(&self) -> bool
fn has_b0_s8(&self) -> bool
Whether the rule contains both B0
and S8
.
In a rule that contains B0
, a dead cell would become ALIVE
in the next
generation, if all its neighbors in this generation are dead.
In a rule that contains S8
, a living cell would stay ALIVE
in the next
generation, if all its neighbors in this generation are alive.
sourcefn new_desc(state: State, succ_state: State) -> Self::Desc
fn new_desc(state: State, succ_state: State) -> Self::Desc
Generates a neighborhood descriptor which says that all neighboring
cells have states state
, and the successor has state succ_state
.
sourcefn update_desc(cell: &LifeCell<Self>, state: State, new: bool)
fn update_desc(cell: &LifeCell<Self>, state: State, new: bool)
Updates the neighborhood descriptors of all neighbors and the predecessor when the state of one cell is changed.
The state
is the new state of the cell when new
is true,
the old state when new
is false.
sourcefn consistify<A: Algorithm<Self>>(
world: &mut World<Self, A>,
cell: CellRef<Self>
) -> Result<(), A::ConflReason>
fn consistify<A: Algorithm<Self>>( world: &mut World<Self, A>, cell: CellRef<Self> ) -> Result<(), A::ConflReason>
Consistifies a cell.
Examines the state and the neighborhood descriptor of the cell, and makes sure that it can validly produce the cell in the next generation. If possible, determines the states of some of the cells involved.
Returns false
if there is a conflict,
true
if the cells are consistent.