Trait rlifesrc_lib::search::Algorithm
source · pub trait Algorithm<R: Rule>: Sealed {
type Reason: Reason<R>;
type ConflReason;
// Required methods
fn new() -> Self;
fn confl_from_cell(cell: CellRef<R>) -> Self::ConflReason;
fn confl_from_sym(cell: CellRef<R>, sym: CellRef<R>) -> Self::ConflReason;
fn init_front(world: World<R, Self>) -> World<R, Self>;
fn set_cell(
world: &mut World<R, Self>,
cell: CellRef<R>,
state: State,
reason: Self::Reason
) -> Result<(), Self::ConflReason>;
fn go(world: &mut World<R, Self>, step: &mut u64) -> bool;
fn retreat(world: &mut World<R, Self>) -> bool;
fn deser_reason(
world: &World<R, Self>,
ser: &ReasonSer
) -> Result<Self::Reason, Error>;
}
Expand description
The search algorithms.
Currently only two algorithms are supported:
LifeSrc
: The default algorithm based on David Bell’s lifesrc.Backjump
: (Experimental) Adding Backjumping to the original lifesrc algorithm. Very slow. Do not use it.
This trait is sealed and cannot be implemented outside of this crate.
Required Associated Types§
sourcetype ConflReason
type ConflReason
Reasons for a conflict. Ignored in LifeSrc
algorithm.
Required Methods§
sourcefn confl_from_cell(cell: CellRef<R>) -> Self::ConflReason
fn confl_from_cell(cell: CellRef<R>) -> Self::ConflReason
Conflict when constitifying a cell.
sourcefn confl_from_sym(cell: CellRef<R>, sym: CellRef<R>) -> Self::ConflReason
fn confl_from_sym(cell: CellRef<R>, sym: CellRef<R>) -> Self::ConflReason
Conflict from symmetry.
sourcefn init_front(world: World<R, Self>) -> World<R, Self>
fn init_front(world: World<R, Self>) -> World<R, Self>
Conflict when constitifying a cell.
sourcefn set_cell(
world: &mut World<R, Self>,
cell: CellRef<R>,
state: State,
reason: Self::Reason
) -> Result<(), Self::ConflReason>
fn set_cell( world: &mut World<R, Self>, cell: CellRef<R>, state: State, reason: Self::Reason ) -> Result<(), Self::ConflReason>
sourcefn go(world: &mut World<R, Self>, step: &mut u64) -> bool
fn go(world: &mut World<R, Self>, step: &mut u64) -> bool
Keeps proceeding and backtracking,
until there are no more cells to examine (and returns true
),
or the backtracking goes back to the time before the first cell is set
(and returns false
).
It also records the number of steps it has walked in the parameter
step
.
Object Safety§
This trait is not object safe.