Show / Hide Table of Contents

Class StandardRuleKeeper

Enforces the standard rules: uniqueness in each row, column, and box.

Inheritance
object
StandardRuleKeeper
Implements
IRuleKeeper
IMissingRowValuesTracker
IMissingColumnValuesTracker
IMissingBoxValuesTracker
IRule
Inherited Members
object.Equals(object)
object.Equals(object, object)
object.GetHashCode()
object.GetType()
object.MemberwiseClone()
object.ReferenceEquals(object, object)
object.ToString()
Namespace: SudokuSpice.RuleBased
Assembly: SudokuSpice.dll
Syntax
public class StandardRuleKeeper : IRuleKeeper, IMissingRowValuesTracker, IMissingColumnValuesTracker, IMissingBoxValuesTracker, IRule

Constructors

| Edit this page View Source

StandardRuleKeeper()

Constructs rule keeper that enforces standard Sudoku rules.

Declaration
public StandardRuleKeeper()

Methods

| Edit this page View Source

CopyWithNewReference(IReadOnlyPuzzle?)

Not implemented.

Declaration
public IRule CopyWithNewReference(IReadOnlyPuzzle? puzzle)
Parameters
Type Name Description
IReadOnlyPuzzle puzzle
Returns
Type Description
IRule
Exceptions
Type Condition
NotImplementedException

Always

| Edit this page View Source

CopyWithNewReferences(IReadOnlyPuzzleWithMutablePossibleValues?)

Creates a deep copy of this rule keeper, including copies of any IRules it contains, with updated internal IReadOnlyPuzzleWithMutablePossibleValues.

Declaration
public IRuleKeeper CopyWithNewReferences(IReadOnlyPuzzleWithMutablePossibleValues? puzzle)
Parameters
Type Name Description
IReadOnlyPuzzleWithMutablePossibleValues puzzle

The new puzzle reference. Should contain the same data as the current puzzle instance.

Returns
Type Description
IRuleKeeper
| Edit this page View Source

GetMissingValuesForBox(int)

Returns all the values that still need to be set in the given box.

Declaration
public BitVector GetMissingValuesForBox(int box)
Parameters
Type Name Description
int box
Returns
Type Description
BitVector
| Edit this page View Source

GetMissingValuesForColumn(int)

Returns all the values that still need to be set in the given column.

Declaration
public BitVector GetMissingValuesForColumn(int column)
Parameters
Type Name Description
int column
Returns
Type Description
BitVector
| Edit this page View Source

GetMissingValuesForRow(int)

Returns all the values that still need to be set in the given row.

Declaration
public BitVector GetMissingValuesForRow(int row)
Parameters
Type Name Description
int row
Returns
Type Description
BitVector
| Edit this page View Source

GetPossibleValues(in Coordinate)

Not implemented.

Declaration
public BitVector GetPossibleValues(in Coordinate c)
Parameters
Type Name Description
Coordinate c
Returns
Type Description
BitVector
Exceptions
Type Condition
NotImplementedException

Always

| Edit this page View Source

GetRules()

Gets the IRules enforced by this rule keeper.

Declaration
public ReadOnlySpan<IRule> GetRules()
Returns
Type Description
ReadOnlySpan<IRule>
| Edit this page View Source

Revert(in Coordinate, int)

Not implemented.

Declaration
public void Revert(in Coordinate c, int val)
Parameters
Type Name Description
Coordinate c
int val
Exceptions
Type Condition
NotImplementedException

Always

| Edit this page View Source

Revert(in Coordinate, int, CoordinateTracker)

Not implemented.

Declaration
public void Revert(in Coordinate c, int val, CoordinateTracker coordTracker)
Parameters
Type Name Description
Coordinate c
int val
CoordinateTracker coordTracker
Exceptions
Type Condition
NotImplementedException

Always

| Edit this page View Source

TryInit(IReadOnlyPuzzle, BitVector)

Not implemented.

Declaration
public bool TryInit(IReadOnlyPuzzle puzzle, BitVector uniquePossibleValues)
Parameters
Type Name Description
IReadOnlyPuzzle puzzle
BitVector uniquePossibleValues
Returns
Type Description
bool
Exceptions
Type Condition
NotImplementedException

Always

| Edit this page View Source

TryInit(IReadOnlyPuzzleWithMutablePossibleValues)

Tries to initialize this rule keeper to solve the given puzzle.

When reusing a rule keeper to solve multiple puzzles, this must be called with each new puzzle to be solved.

Declaration
public bool TryInit(IReadOnlyPuzzleWithMutablePossibleValues puzzle)
Parameters
Type Name Description
IReadOnlyPuzzleWithMutablePossibleValues puzzle

The puzzle to be solved.

Returns
Type Description
bool

False if the rule keeper couldn't be initialized, for example if the puzzle already violates one of the rules. Else returns true.

Remarks

In general, it doesn't make sense to want to maintain the previous state if this method fails. Therefore, it is not guaranteed that the rule keeper's state is unchanged on failure.

| Edit this page View Source

TrySet(in Coordinate, int)

Updates possible values based on setting the given coordinate to the given value.

If this update fails (i.e. it leads to an unset square with no possible values), then it returns false and leaves all possible values unchanged.

Declaration
public bool TrySet(in Coordinate c, int value)
Parameters
Type Name Description
Coordinate c

The coordinate to update.

int value

The value to set c to.

Returns
Type Description
bool

True if the possible values have been updated and the rules are still satisfied.

| Edit this page View Source

Unset(in Coordinate, int)

Undoes an update for the given value at the specified coordinate.

Declaration
public void Unset(in Coordinate c, int value)
Parameters
Type Name Description
Coordinate c

The coordinate where a value is being unset.

int value

The value being unset.

| Edit this page View Source

Update(in Coordinate, int, CoordinateTracker)

Not implemented.

Declaration
public void Update(in Coordinate c, int val, CoordinateTracker coordTracker)
Parameters
Type Name Description
Coordinate c
int val
CoordinateTracker coordTracker
Exceptions
Type Condition
NotImplementedException

Always

Implements

IRuleKeeper
IMissingRowValuesTracker
IMissingColumnValuesTracker
IMissingBoxValuesTracker
IRule
  • Edit this page
  • View Source
In this article
Back to top Generated by DocFX