Class UniqueInRowHeuristic
Checks for any squares that are the unique provider of a given possible value within a row. Sets the possible values for those squares to just their unique value.
Inheritance
Implements
Inherited Members
Namespace: SudokuSpice.RuleBased.Heuristics
Assembly: SudokuSpice.dll
Syntax
public class UniqueInRowHeuristic : IHeuristic
Remarks
For example, if a row had three unset squares with possible values: A: [1, 2]
,
B: [1, 2]
, and C: [1, 2, 3]
, then this would set C
's possible values
to [3]
.
Constructors
| Improve this Doc View SourceUniqueInRowHeuristic(IMissingRowValuesTracker)
Creates the heuristic.
Declaration
public UniqueInRowHeuristic(IMissingRowValuesTracker rowValuesTracker)
Parameters
Type | Name | Description |
---|---|---|
IMissingRowValuesTracker | rowValuesTracker | Something that tracks the possible values for each row. Rules often do this already, for example. |
Methods
| Improve this Doc View SourceCopyWithNewReferences(IReadOnlyPuzzleWithMutablePossibleValues, ReadOnlySpan<IRule>)
Creates a deep copy of this heuristic. Requires rules
to contain an
IMissingRowValuesTracker.
Declaration
public IHeuristic CopyWithNewReferences(IReadOnlyPuzzleWithMutablePossibleValues puzzle, ReadOnlySpan<IRule> rules)
Parameters
Type | Name | Description |
---|---|---|
IReadOnlyPuzzleWithMutablePossibleValues | puzzle | |
System.ReadOnlySpan<IRule> | rules |
Returns
Type | Description |
---|---|
IHeuristic |
TryInitFor(IReadOnlyPuzzleWithMutablePossibleValues)
Tries to initialize this heuristic for solving the given puzzle.
Declaration
public bool TryInitFor(IReadOnlyPuzzleWithMutablePossibleValues puzzle)
Parameters
Type | Name | Description |
---|---|---|
IReadOnlyPuzzleWithMutablePossibleValues | puzzle | The puzzle to solve. |
Returns
Type | Description |
---|---|
System.Boolean | False if this heuristic cannot be initialized for the given puzzle, else 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 heuristic's state is unchanged on failure.
UndoLastUpdate()
Undoes the last modifications made by this heuristic.
Declaration
public void UndoLastUpdate()
UpdateAll()
Updates all the current possible values.
Declaration
public bool UpdateAll()
Returns
Type | Description |
---|---|
System.Boolean | Returns true if any modifications were made. |