Class StandardRuleKeeper
Enforces the standard rules: uniqueness in each row, column, and box.
Inheritance
Implements
Inherited Members
Namespace: SudokuSpice.RuleBased
Assembly: SudokuSpice.dll
Syntax
public class StandardRuleKeeper : IRuleKeeper, IMissingRowValuesTracker, IMissingColumnValuesTracker, IMissingBoxValuesTracker, IRule
Constructors
| Improve this Doc View SourceStandardRuleKeeper()
Constructs rule keeper that enforces standard Sudoku rules.
Declaration
public StandardRuleKeeper()
Methods
| Improve this Doc View SourceCopyWithNewReference(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 |
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 |
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 |
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 |
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 |
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 |
GetRules()
Gets the IRules enforced by this rule keeper.
Declaration
public ReadOnlySpan<IRule> GetRules()
Returns
| Type | Description |
|---|---|
| System.ReadOnlySpan<IRule> |
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 |
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 |
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 |
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.
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 |
Returns
| Type | Description |
|---|---|
| System.Boolean | True if the possible values have been updated and the rules are still satisfied. |
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. |
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 |