コード例 #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 UniqueInRowHeuristic(
     UniqueInRowHeuristic existing,
     IReadOnlyPuzzle puzzle,
     PossibleValues possibleValues,
     IMissingRowValuesTracker rule)
 {
     _puzzle                 = puzzle;
     _possibleValues         = possibleValues;
     _rowTracker             = rule;
     _possiblesToCheckInRow  = (BitVector[])existing._possiblesToCheckInRow.Clone();
     _previousPossiblesStack = new Stack <IReadOnlyDictionary <Coordinate, BitVector> >(
         existing._previousPossiblesStack);
 }
コード例 #4
0
 private UniqueInRowHeuristic(
     UniqueInRowHeuristic existing,
     IReadOnlyPuzzleWithMutablePossibleValues?puzzle,
     IMissingRowValuesTracker tracker)
 {
     _rowTracker = tracker;
     _puzzle     = puzzle;
     if (existing._helper is not null &&
         puzzle 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);
 }