[−][src]Struct graph_solver::BackTrackSolver
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
impl<T> BackTrackSolver<T> where
T: Puzzle,
[src]
T: Puzzle,
pub fn new(puzzle: T, settings: SolveSettings) -> BackTrackSolver<T>
[src]
Creates a new solver.
pub fn solve<F, G>(self, f: F, g: G) -> Option<Solution<T>> where
F: FnMut(&T) -> Option<<T as Puzzle>::Pos>,
G: FnMut(&T, <T as Puzzle>::Pos) -> Vec<<T as Puzzle>::Val>,
[src]
F: FnMut(&T) -> Option<<T as Puzzle>::Pos>,
G: FnMut(&T, <T as Puzzle>::Pos) -> Vec<<T as Puzzle>::Val>,
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> RefUnwindSafe for BackTrackSolver<T> where
T: RefUnwindSafe,
<T as Puzzle>::Pos: RefUnwindSafe,
<T as Puzzle>::Val: RefUnwindSafe,
T: RefUnwindSafe,
<T as Puzzle>::Pos: RefUnwindSafe,
<T as Puzzle>::Val: RefUnwindSafe,
impl<T> Send for BackTrackSolver<T> where
T: Send,
<T as Puzzle>::Pos: Send,
<T as Puzzle>::Val: Send,
T: Send,
<T as Puzzle>::Pos: Send,
<T as Puzzle>::Val: Send,
impl<T> Sync for BackTrackSolver<T> where
T: Sync,
<T as Puzzle>::Pos: Sync,
<T as Puzzle>::Val: Sync,
T: Sync,
<T as Puzzle>::Pos: Sync,
<T as Puzzle>::Val: Sync,
impl<T> Unpin for BackTrackSolver<T> where
T: Unpin,
<T as Puzzle>::Pos: Unpin,
<T as Puzzle>::Val: Unpin,
T: Unpin,
<T as Puzzle>::Pos: Unpin,
<T as Puzzle>::Val: Unpin,
impl<T> UnwindSafe for BackTrackSolver<T> where
T: UnwindSafe,
<T as Puzzle>::Pos: UnwindSafe,
<T as Puzzle>::Val: UnwindSafe,
T: UnwindSafe,
<T as Puzzle>::Pos: UnwindSafe,
<T as Puzzle>::Val: UnwindSafe,
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,