public UniqueInRowHeuristic(IReadOnlyPuzzle puzzle, PossibleValues possibleValues, IMissingRowValuesTracker rule)
 {
     _puzzle                 = puzzle;
     _possibleValues         = possibleValues;
     _rowTracker             = rule;
     _possiblesToCheckInRow  = new BitVector[puzzle.Size];
     _previousPossiblesStack = new Stack <IReadOnlyDictionary <Coordinate, BitVector> >();
 }
 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);
 }
 /// <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>();
 }
 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);
 }
Beispiel #5
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);
     }
 }
Beispiel #6
0
 /// <summary>
 /// Creates the heuristic.
 /// </summary>
 /// <param name="rowValuesTracker">
 /// Something that tracks the possible values for each row. Rules often do this already,
 /// for example.
 /// </param>
 public UniqueInRowHeuristic(IMissingRowValuesTracker rowValuesTracker)
 {
     _rowTracker = rowValuesTracker;
 }