예제 #1
0
 public StandardHeuristic(IReadOnlyBoxPuzzle puzzle, PossibleValues possibleValues,
                          IMissingRowValuesTracker rowRule, IMissingColumnValuesTracker columnRule, IMissingBoxValuesTracker boxRule)
 {
     _rowHeuristic     = new UniqueInRowHeuristic(puzzle, possibleValues, rowRule);
     _columnHeuristic  = new UniqueInColumnHeuristic(puzzle, possibleValues, columnRule);
     _boxHeuristic     = new UniqueInBoxHeuristic(puzzle, possibleValues, boxRule);
     _numHeuristicsRan = new Stack <int>(puzzle.NumEmptySquares);
 }
예제 #2
0
 /// <summary>
 /// Creates a standard heuristic that combines the <see cref="UniqueInRowHeuristic"/>,
 /// <see cref="UniqueInColumnHeuristic"/>, and <see cref="UniqueInBoxHeuristic"/>.
 /// </summary>
 /// <param name="rowValuesTracker">
 /// Something that tracks the possible values for each row.
 /// </param>
 /// <param name="columnValuesTracker">
 /// Something that tracks the possible values for each column.
 /// </param>
 /// <param name="boxValuesTracker">
 /// Something that tracks the possible values for each box.
 /// </param>
 public StandardHeuristic(
     IMissingRowValuesTracker rowValuesTracker,
     IMissingColumnValuesTracker columnValuesTracker,
     IMissingBoxValuesTracker boxValuesTracker)
 {
     _rowHeuristic     = new UniqueInRowHeuristic(rowValuesTracker);
     _columnHeuristic  = new UniqueInColumnHeuristic(columnValuesTracker);
     _boxHeuristic     = new UniqueInBoxHeuristic(boxValuesTracker);
     _numHeuristicsRan = new Stack <int>();
 }
예제 #3
0
 private UniqueInBoxHeuristic(
     UniqueInBoxHeuristic existing,
     IReadOnlyBoxPuzzle puzzle,
     PossibleValues possibleValues,
     IMissingBoxValuesTracker rule)
 {
     _puzzle                 = puzzle;
     _possibleValues         = possibleValues;
     _boxTracker             = rule;
     _possiblesToCheckInBox  = (BitVector[])existing._possiblesToCheckInBox.Clone();
     _previousPossiblesStack = new Stack <IReadOnlyDictionary <Coordinate, BitVector> >(
         existing._previousPossiblesStack);
 }
예제 #4
0
 private UniqueInBoxHeuristic(
     UniqueInBoxHeuristic existing,
     IReadOnlyPuzzleWithMutablePossibleValues?puzzle,
     IMissingBoxValuesTracker boxTracker)
 {
     _boxTracker = boxTracker;
     _boxSize    = existing._boxSize;
     _puzzle     = puzzle;
     if (puzzle is not null && existing._helper is not null)
     {
         _helper = existing._helper.CopyWithNewReference(puzzle);
     }
 }
예제 #5
0
 private StandardHeuristic(
     StandardHeuristic existing,
     IReadOnlyPuzzleWithMutablePossibleValues?puzzle,
     ReadOnlySpan <IRule> rules)
 {
     _rowHeuristic = (UniqueInRowHeuristic)existing._rowHeuristic.CopyWithNewReferences(
         puzzle, rules);
     _columnHeuristic = (UniqueInColumnHeuristic)existing._columnHeuristic
                        .CopyWithNewReferences(puzzle, rules);
     _boxHeuristic = (UniqueInBoxHeuristic)existing._boxHeuristic.CopyWithNewReferences(
         puzzle, rules);
     _numHeuristicsRan = new Stack <int>(existing._numHeuristicsRan);
 }
예제 #6
0
 private StandardHeuristic(
     StandardHeuristic existing,
     IReadOnlyPuzzle puzzle,
     PossibleValues possibleValues,
     IReadOnlyList <ISudokuRule> rules)
 {
     _rowHeuristic = (UniqueInRowHeuristic)existing._rowHeuristic.CopyWithNewReferences(
         puzzle, possibleValues, rules);
     _columnHeuristic = (UniqueInColumnHeuristic)existing._columnHeuristic
                        .CopyWithNewReferences(puzzle, possibleValues, rules);
     _boxHeuristic = (UniqueInBoxHeuristic)existing._boxHeuristic.CopyWithNewReferences(
         puzzle, possibleValues, rules);
     _numHeuristicsRan = new Stack <int>(existing._numHeuristicsRan);
 }