Struct rlifesrc_lib::cells::LifeCell
source · 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>
impl<R: Rule> LifeCell<R>
sourcepub(crate) fn new(coord: Coord, background: State, succ_state: State) -> Self
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
.
sourcepub(crate) fn update_desc(&self, state: State, new: bool)
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.