pub struct LifeCell<R: Rule> {
    pub coord: Coord,
    pub(crate) background: State,
    pub(crate) state: Cell<Option<State>>,
    pub(crate) desc: Cell<R::Desc>,
    pub(crate) pred: Option<CellRef<R>>,
    pub(crate) succ: Option<CellRef<R>>,
    pub(crate) nbhd: [Option<CellRef<R>>; 8],
    pub(crate) sym: Vec<CellRef<R>>,
    pub(crate) next: Option<CellRef<R>>,
    pub(crate) is_front: bool,
    pub(crate) level: Cell<u32>,
    pub(crate) seen: Cell<bool>,
}
Expand description

A cell in the cellular automaton.

The name LifeCell is chosen to avoid ambiguity with std::cell::Cell.

Fields§

§coord: Coord

The coordinates of a cell.

§background: State

The background state of the cell.

For rules without B0, it is always DEAD.

For rules with B0, the background changes periodically. For example, for non-Generations rules, it is DEAD on even generations, ALIVE on odd generations.

§state: Cell<Option<State>>

The state of the cell.

None means that the state of the cell is unknown.

§desc: Cell<R::Desc>

The “neighborhood descriptors” of the cell.

It describes the states of the cell itself, its neighbors, and its successor.

§pred: Option<CellRef<R>>

The predecessor of the cell.

The cell in the last generation at the same position.

§succ: Option<CellRef<R>>

The successor of the cell.

The cell in the next generation at the same position.

§nbhd: [Option<CellRef<R>>; 8]

The eight cells in the neighborhood.

§sym: Vec<CellRef<R>>

The cells in the same generation that must has the same state with this cell because of the symmetry.

§next: Option<CellRef<R>>

The next cell to be searched when searching for an unknown cell.

§is_front: bool

Whether the cell is on the first row or column.

Here the choice of row or column depends on the search order.

§level: Cell<u32>

The decision level for assigning the cell state.

Only used when backjumping is enabled.

§seen: Cell<bool>

Whether the cell has been seen in the analysis.

Only used when backjumping is enabled.

Implementations§

source§

impl<R: Rule> LifeCell<R>

source

pub(crate) fn new(coord: Coord, background: State, succ_state: State) -> Self

Generates a new cell with background state, such that its neighborhood descriptor says that all neighboring cells also have the same state.

is_front are set to false.

source

pub(crate) fn update_desc(&self, state: State, new: bool)

Updates the neighborhood descriptors of all neighbors and the predecessor when the state of one cell is changed.

Here state is the new state of the cell when new is true, the old state when new is false.

Trait Implementations§

source§

impl<R: Rule<Desc = D>, D: Copy + Debug> Debug for LifeCell<R>

source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<R> !RefUnwindSafe for LifeCell<R>

§

impl<R> !Send for LifeCell<R>

§

impl<R> !Sync for LifeCell<R>

§

impl<R> Unpin for LifeCell<R>where <R as Rule>::Desc: Unpin,

§

impl<R> !UnwindSafe for LifeCell<R>

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, 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