Struct sudoku_variants::solver::strategy::impls::BoundedCellsBacktrackingStrategy [−][src]
A Strategy which looks for groups in which some number can only occur in a limited number of cells (up to a specified maximum) and tries all of them. It then uses a wrapped strategy to find deductions in all paths. If any of those deductions hold for all options, they are stored in the metadata.
As an example, consider the following situation:
╔═══╤═══╤═══╦═══╤═══╤═══╦═══╤═══╤═══╗
║ │ │ ║ │ 5 │ ║ │ │ ║
╟───┼───┼───╫───┼───┼───╫───┼───┼───╢
║ 1 │ 2 │ 3 ║ │ │ ║ │ │ ║
╟───┼───┼───╫───┼───┼───╫───┼───┼───╢
║ 4 │ │ ║ │ │ ║ X │ │ ║
╠═══╪═══╪═══╬═══╪═══╪═══╬═══╪═══╪═══╣
║ 2 │ │ ║ │ │ ║ X │ │ ║
╟───┼───┼───╫───┼───┼───╫───┼───┼───╢
║ │ │ ║ │ │ 5 ║ │ │ ║
╟───┼───┼───╫───┼───┼───╫───┼───┼───╢
║ 3 │ 1 │ 4 ║ │ │ ║ │ │ ║
╠═══╪═══╪═══╬═══╪═══╪═══╬═══╪═══╪═══╣
║ │ Y │ Y ║ │ │ ║ │ │ ║
╟───┼───┼───╫───┼───┼───╫───┼───┼───╢
║ │ Y │ Y ║ │ │ ║ │ │ ║
╟───┼───┼───╫───┼───┼───╫───┼───┼───╢
║ │ Y │ Y ║ │ │ ║ │ │ ║
╚═══╧═══╧═══╩═══╧═══╧═══╩═══╧═══╧═══╝
In this configuration, a bounded cells backtracking strategy without any wrapped stratey (i.e. a NoStrategy) with a maximum of 2 cells to consider would find that the cells marked with X cannot be a 5. This is because both in the top-left and the top-central box, there are two places for 5s each, both in the same rows, thus excluding a 5 from the X-cells. Furthermore, if an OnlyCellStrategy with at least 1 application is used as the continuation strategy, the bounded cells backtracking strategy would be able to deduce that fives must always be in columns 2 and 3 in the top-left and top-central box and thus all cells marked with Y cannot be a 5.
Note that this strategy contains some common strategies with different names. For example a bounded cells backtracking strategy with a limit of 2 cells and an OnlyCellStrategy with 1 application would find X-Wings.
Implementations
impl<FC, FA, S> BoundedCellsBacktrackingStrategy<FC, FA, S> where
FC: Fn(usize) -> usize,
FA: Fn(usize) -> Option<usize>,
S: Strategy,
[src]
FC: Fn(usize) -> usize,
FA: Fn(usize) -> Option<usize>,
S: Strategy,
pub fn new(
max_cells_computer: FC,
max_applications_computer: FA,
continuation_strategy: S
) -> BoundedCellsBacktrackingStrategy<FC, FA, S>
[src]
max_cells_computer: FC,
max_applications_computer: FA,
continuation_strategy: S
) -> BoundedCellsBacktrackingStrategy<FC, FA, S>
Creates a new bounded cells backtracking strategy.
Arguments
max_cells_computer
: A closure that, given the grid size, computes the maximum number of cells in a group in which a number can be for this strategy to consider all of them.max_applications_computer
: A closure that, given the grid size, computes the maximum number of times the continuation strategy may be applied for each considered cell before no further inference is done. If no limit is desired, this may returnNone
.continuation_strategy
: The Strategy with which each considered cell is developed to find any inferences.
Trait Implementations
impl<FC: Clone, FA: Clone, S: Clone> Clone for BoundedCellsBacktrackingStrategy<FC, FA, S> where
FC: Fn(usize) -> usize,
FA: Fn(usize) -> Option<usize>,
S: Strategy,
[src]
FC: Fn(usize) -> usize,
FA: Fn(usize) -> Option<usize>,
S: Strategy,
fn clone(&self) -> BoundedCellsBacktrackingStrategy<FC, FA, S>
[src]
pub fn clone_from(&mut self, source: &Self)
1.0.0[src]
impl<FC, FA, S> Strategy for BoundedCellsBacktrackingStrategy<FC, FA, S> where
FC: Fn(usize) -> usize,
FA: Fn(usize) -> Option<usize>,
S: Strategy,
[src]
FC: Fn(usize) -> usize,
FA: Fn(usize) -> Option<usize>,
S: Strategy,
fn apply(&self, sudoku_info: &mut SudokuInfo<impl Constraint + Clone>) -> bool
[src]
Auto Trait Implementations
impl<FC, FA, S> RefUnwindSafe for BoundedCellsBacktrackingStrategy<FC, FA, S> where
FA: RefUnwindSafe,
FC: RefUnwindSafe,
S: RefUnwindSafe,
FA: RefUnwindSafe,
FC: RefUnwindSafe,
S: RefUnwindSafe,
impl<FC, FA, S> Send for BoundedCellsBacktrackingStrategy<FC, FA, S> where
FA: Send,
FC: Send,
S: Send,
FA: Send,
FC: Send,
S: Send,
impl<FC, FA, S> Sync for BoundedCellsBacktrackingStrategy<FC, FA, S> where
FA: Sync,
FC: Sync,
S: Sync,
FA: Sync,
FC: Sync,
S: Sync,
impl<FC, FA, S> Unpin for BoundedCellsBacktrackingStrategy<FC, FA, S> where
FA: Unpin,
FC: Unpin,
S: Unpin,
FA: Unpin,
FC: Unpin,
S: Unpin,
impl<FC, FA, S> UnwindSafe for BoundedCellsBacktrackingStrategy<FC, FA, S> where
FA: UnwindSafe,
FC: UnwindSafe,
S: UnwindSafe,
FA: UnwindSafe,
FC: UnwindSafe,
S: 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,
pub 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> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
pub fn to_owned(&self) -> T
[src]
pub fn clone_into(&self, target: &mut T)
[src]
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.
pub 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>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
pub fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
V: MultiLane<T>,