Struct quickbacktrack::MultiBackTrackSolver
[−]
[src]
pub struct MultiBackTrackSolver<T> where
T: Puzzle, { pub states: Vec<Vec<T>>, pub choice: Vec<Vec<(T::Pos, Vec<T::Val>)>>, pub settings: SolveSettings, }
Solves puzzle using multiple strategies at the same time. Each strategy is evaluated one step by turn until a solution is found.
Fields
states: Vec<Vec<T>>
Stores the states.
choice: Vec<Vec<(T::Pos, Vec<T::Val>)>>
Stores the choices for the states.
settings: SolveSettings
Search for simple solutions.
Methods
impl<T> MultiBackTrackSolver<T> where
T: Puzzle,
[src]
T: Puzzle,
fn new(settings: SolveSettings) -> MultiBackTrackSolver<T>
Creates a new solver.
fn solve(
self,
puzzle: T,
strategies: &[(fn(_: &T) -> Option<T::Pos>, fn(_: &T, _: T::Pos) -> Vec<T::Val>)]
) -> Option<Solution<T>>
self,
puzzle: T,
strategies: &[(fn(_: &T) -> Option<T::Pos>, fn(_: &T, _: T::Pos) -> Vec<T::Val>)]
) -> Option<Solution<T>>
Solves puzzle, using a closure to look for best position to set a value next, and a closure for picking options in preferred order.
The second closure returns possible values at a given position. The last move in the list has highest priority, because the solver pops the values in turn.
If you have problems compiling, annotate type (fn(&_) -> _, fn(&_, _) -> _)
to
the list of strategies, e.g. Vec<(fn(&_) -> _, fn(&_, _) -> _)>
or
&[(fn(&_) -> _, fn(&_, _) -> _)]
.