Class RowUniquenessRule
Restricts that each row contains all unique values.
Inherited Members
Namespace: SudokuSpice.RuleBased.Rules
Assembly: SudokuSpice.dll
Syntax
public class RowUniquenessRule : UniquenessRule, IMissingRowValuesTracker, IRule
Constructors
| Edit this page View SourceRowUniquenessRule()
Declaration
public RowUniquenessRule()
Methods
| Edit this page View SourceCopyWithNewReference(IReadOnlyPuzzle?)
Creates a deep copy of this IRule, with any internal IReadOnlyPuzzle
references updated to the given puzzle.
Declaration
public override IRule CopyWithNewReference(IReadOnlyPuzzle? puzzle)
Parameters
| Type | Name | Description |
|---|---|---|
| IReadOnlyPuzzle | puzzle | The new puzzle reference to use. To ensure this rule's internal state is correct, this puzzle should contain the same data as the current puzzle referenced by this rule. |
Returns
| Type | Description |
|---|---|
| IRule |
Overrides
| Edit this page View SourceGetDimension(in Coordinate)
Gets the dimension for a coordinate.
Declaration
protected override int GetDimension(in Coordinate c)
Parameters
| Type | Name | Description |
|---|---|---|
| Coordinate | c |
Returns
| Type | Description |
|---|---|
| int |
Overrides
| Edit this page View SourceGetMissingValuesForRow(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 |
GetNumDimensions(IReadOnlyPuzzle)
Returns the number of dimensions that will be enforced to contain unique values.
Declaration
protected override int GetNumDimensions(IReadOnlyPuzzle puzzle)
Parameters
| Type | Name | Description |
|---|---|---|
| IReadOnlyPuzzle | puzzle | The puzzle for which to determine the number of dimensions. |
Returns
| Type | Description |
|---|---|
| int |
Overrides
| Edit this page View SourceTrackUnsetCoordinatesOnSameDimension(int, in Coordinate, CoordinateTracker)
Adds the coordinates of unset values on the given dimension to the given tracker.
Declaration
protected override void TrackUnsetCoordinatesOnSameDimension(int dimension, in Coordinate source, CoordinateTracker tracker)
Parameters
| Type | Name | Description |
|---|---|---|
| int | dimension | The dimension to search. |
| Coordinate | source | The source coordinate for the change; should be skipped. |
| CoordinateTracker | tracker | The tracker to add coordiantes to. |
Overrides
| Edit this page View SourceTryInit(IReadOnlyPuzzle, BitVector)
Tries to initialize this rule to prepare to solve the given puzzle.
Declaration
public override bool TryInit(IReadOnlyPuzzle puzzle, BitVector uniquePossibleValues)
Parameters
| Type | Name | Description |
|---|---|---|
| IReadOnlyPuzzle | puzzle | The puzzle to be solved. |
| BitVector | uniquePossibleValues | All the unique possible values for this puzzle. |
Returns
| Type | Description |
|---|---|
| bool | False if the puzzle violates this rule and initialization fails, else true. |
Overrides
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's state is unchanged on failure.