Show / Hide Table of Contents

Class StandardRuleKeeper

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

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

Constructors

| Improve this Doc View Source

StandardRuleKeeper()

Constructs rule keeper that enforces standard Sudoku rules.

Declaration
public StandardRuleKeeper()

Methods

| Improve this Doc 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
System.NotImplementedException

Always

| Improve this Doc 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
| Improve this Doc View Source

GetMissingValuesForBox(Int32)

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

Declaration
public BitVector GetMissingValuesForBox(int box)
Parameters
Type Name Description
System.Int32 box
Returns
Type Description
BitVector
| Improve this Doc View Source

GetMissingValuesForColumn(Int32)

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

Declaration
public BitVector GetMissingValuesForColumn(int column)
Parameters
Type Name Description
System.Int32 column
Returns
Type Description
BitVector
| Improve this Doc View Source

GetMissingValuesForRow(Int32)

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

Declaration
public BitVector GetMissingValuesForRow(int row)
Parameters
Type Name Description
System.Int32 row
Returns
Type Description
BitVector
| Improve this Doc View Source

GetPossibleValues(Coordinate)

Not implemented.

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

Always

| Improve this Doc View Source

GetRules()

Gets the IRules enforced by this rule keeper.

Declaration
public ReadOnlySpan<IRule> GetRules()
Returns
Type Description
System.ReadOnlySpan<IRule>
| Improve this Doc View Source

Revert(Coordinate, Int32)

Not implemented.

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

Always

| Improve this Doc View Source

Revert(Coordinate, Int32, CoordinateTracker)

Not implemented.

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

Always

| Improve this Doc View Source

TryInit(IReadOnlyPuzzle, BitVector)

Not implemented.

Declaration
public bool TryInit(IReadOnlyPuzzle puzzle, BitVector allPossibleValues)
Parameters
Type Name Description
IReadOnlyPuzzle puzzle
BitVector allPossibleValues
Returns
Type Description
System.Boolean
Exceptions
Type Condition
System.NotImplementedException

Always

| Improve this Doc 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
System.Boolean

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.

| Improve this Doc View Source

TrySet(Coordinate, Int32)

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.

System.Int32 value

The value to set c to.

Returns
Type Description
System.Boolean

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

| Improve this Doc View Source

Unset(Coordinate, Int32)

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.

System.Int32 value

The value being unset.

| Improve this Doc View Source

Update(Coordinate, Int32, CoordinateTracker)

Not implemented.

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

Always

Implements

IRuleKeeper
IMissingRowValuesTracker
IMissingColumnValuesTracker
IMissingBoxValuesTracker
IRule
  • Improve this Doc
  • View Source
In This Article
Back to top Generated by DocFX