pub struct BackTrackSolver<T>where
T: Puzzle,{
pub original: T,
pub state: T,
pub prevs: Vec<(<T as Puzzle>::Pos, <T as Puzzle>::Val, bool)>,
pub choice: Vec<(<T as Puzzle>::Pos, Vec<<T as Puzzle>::Val>)>,
pub settings: SolveSettings,
}
Expand description
Solvees puzzles using back tracking.
Fields§
§original: T
Stores the original state.
state: T
Stores the state.
prevs: Vec<(<T as Puzzle>::Pos, <T as Puzzle>::Val, bool)>
Stores the previous values of a position before making a choice. If the flag is true, the value was inserted due to a simple choice.
choice: Vec<(<T as Puzzle>::Pos, Vec<<T as Puzzle>::Val>)>
Stores the choices for the states.
settings: SolveSettings
Search for simple solutions.
Implementations§
Source§impl<T> BackTrackSolver<T>where
T: Puzzle,
impl<T> BackTrackSolver<T>where
T: Puzzle,
Sourcepub fn new(puzzle: T, settings: SolveSettings) -> BackTrackSolver<T>
pub fn new(puzzle: T, settings: SolveSettings) -> BackTrackSolver<T>
Creates a new solver.
Sourcepub fn solve<F, G>(self, f: F, g: G) -> Option<Solution<T>>
pub fn solve<F, G>(self, f: F, g: G) -> 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.
Auto Trait Implementations§
impl<T> Freeze for BackTrackSolver<T>where
T: Freeze,
impl<T> RefUnwindSafe for BackTrackSolver<T>
impl<T> Send for BackTrackSolver<T>
impl<T> Sync for BackTrackSolver<T>
impl<T> Unpin for BackTrackSolver<T>
impl<T> UnwindSafe for BackTrackSolver<T>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more