Esempio n. 1
0
 public UniqueInBoxHeuristic(IReadOnlyBoxPuzzle puzzle, PossibleValues possibleValues, IMissingBoxValuesTracker rule)
 {
     _puzzle                 = puzzle;
     _possibleValues         = possibleValues;
     _boxTracker             = rule;
     _possiblesToCheckInBox  = new BitVector[puzzle.Size];
     _previousPossiblesStack = new Stack <IReadOnlyDictionary <Coordinate, BitVector> >();
 }
Esempio n. 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>();
 }
Esempio n. 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);
 }
 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);
     }
 }
 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 the heuristic.
 /// </summary>
 /// <param name="boxValuesTracker">
 /// Something that tracks the possible values for each box. Rules often do this already,
 /// for example.
 /// </param>
 public UniqueInBoxHeuristic(IMissingBoxValuesTracker boxValuesTracker) : base()
 {
     _boxTracker = boxValuesTracker;
 }