pub struct KingsMoveConstraint;
Expand description
A RelativeCellConstraint that excludes duplicates a Chess-Kings’s move away from the reference cell (orthogonally or diagonally adjacent). Note that some checks performed by this constraint are redundant if standard Sudoku rules apply, since orthogonally adjacent cells are either in the same row or column as the reference cell. In that case, using the DiagonallyAdjacentConstraint is more efficient and has the same effect.
Trait Implementations§
Source§impl Clone for KingsMoveConstraint
impl Clone for KingsMoveConstraint
Source§fn clone(&self) -> KingsMoveConstraint
fn clone(&self) -> KingsMoveConstraint
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moreSource§impl RelativeCellConstraint for KingsMoveConstraint
impl RelativeCellConstraint for KingsMoveConstraint
Source§const RELATIVE_COORDINATES: &'static [(isize, isize)]
const RELATIVE_COORDINATES: &'static [(isize, isize)]
A slice of coordinates relative to the cell in question that must not
contain the same number.
Source§fn is_forbidden(&self, reference_cell: usize, other_cell: usize) -> bool
fn is_forbidden(&self, reference_cell: usize, other_cell: usize) -> bool
Given the contents of the reference cell and one other cell that is
removed by one set of coordinates specified in
RelativeCellConstraint::RELATIVE_COORDINATES, this method determines
whether the reference cell violates the constraint. Since it is assumed
that an empty cell cannot violate the constraint, this method is only
called if both cells contain a number. Read more
Auto Trait Implementations§
impl Freeze for KingsMoveConstraint
impl RefUnwindSafe for KingsMoveConstraint
impl Send for KingsMoveConstraint
impl Sync for KingsMoveConstraint
impl Unpin for KingsMoveConstraint
impl UnwindSafe for KingsMoveConstraint
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
Source§impl<C> CloneConstraint for Cwhere
C: Constraint + Clone + 'static,
impl<C> CloneConstraint for Cwhere
C: Constraint + Clone + 'static,
Source§fn clone_box(&self) -> Box<dyn CloneConstraint>
fn clone_box(&self) -> Box<dyn CloneConstraint>
Clones a trait object of this constraint.
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<C> Constraint for Cwhere
C: RelativeCellConstraint,
impl<C> Constraint for Cwhere
C: RelativeCellConstraint,
Source§fn check_number(
&self,
grid: &SudokuGrid,
column: usize,
row: usize,
number: usize,
) -> bool
fn check_number( &self, grid: &SudokuGrid, column: usize, row: usize, number: usize, ) -> bool
Checks whether the given
number
would fit into the cell specified by
column
and row
into the grid
without violating this constraint.
This function does not have to check whether number
is actually a
valid number for this grid (i.e. in the interval [1, size]). If you
require this guarantee, use
Sudoku::is_valid_number instead. Read moreSource§fn get_groups(&self, _: &SudokuGrid) -> Vec<Vec<(usize, usize)>>
fn get_groups(&self, _: &SudokuGrid) -> Vec<Vec<(usize, usize)>>
Gets a vector of all groups that are defined by this constraint. A
group is a set of cells which may not contain repeated numbers. As an
example, the BlockConstraint defines each block as a group. Some
constraints, such as the KingsMoveConstraint, do not have groups. In
this particular case, a cell removed by a kings-move to the top-left
may be the same as one to the bottom-right, so the cells removed by a
kings-move from any particular cell cannot form a group. Such
constraints should return an empty vector here. Read more
Source§fn check(&self, grid: &SudokuGrid) -> bool
fn check(&self, grid: &SudokuGrid) -> bool
Checks whether the given SudokuGrid matches this constraint, that is,
every cell matches this constraint. By default, this runs
check_cell
on every cell of the grid, which may be inefficient, so custom
implementations may be advantageous.Source§fn check_cell(&self, grid: &SudokuGrid, column: usize, row: usize) -> bool
fn check_cell(&self, grid: &SudokuGrid, column: usize, row: usize) -> bool
Checks whether the cell at the given position in the SudokuGrid
fulfills the constraint. This is the same as calling
check_number
with the same coordinates and the number which is actually filled in
that cell. If the cell is empty, this function always returns true
.