Show / Hide Table of Contents

Interface IRuleKeeper

Namespace: SudokuSpice.RuleBased
Assembly: SudokuSpice.dll
Syntax
public interface IRuleKeeper

Methods

| 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
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

GetRules()

Gets the IRules enforced by this rule keeper.

Declaration
ReadOnlySpan<IRule> GetRules()
Returns
Type Description
System.ReadOnlySpan<IRule>
| 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
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
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
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
In This Article
Back to top Generated by DocFX