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); }
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); } }
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); }
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); }