コード例 #1
0
 /// <inheritdoc/>
 public bool TrySolve(TPuzzle puzzle, bool randomizeGuesses = false)
 {
     if (!SquareTracker <TPuzzle> .TryInit(puzzle, _ruleKeeper, _heuristic, out SquareTracker <TPuzzle>?tracker))
     {
         return(false);
     }
     return(randomizeGuesses ? _TrySolveRandomly(tracker !, new Random()) : _TrySolve(tracker !));
 }
コード例 #2
0
 private SolveStats _ComputeStatsForAllSolutions(
     TPuzzle puzzle, bool validateUniquenessOnly, CancellationToken?cancellationToken)
 {
     cancellationToken?.ThrowIfCancellationRequested();
     // Copy the puzzle so that the given puzzle is not modified.
     if (!SquareTracker <TPuzzle> .TryInit(puzzle.DeepCopy(), _ruleKeeper, _heuristic, out SquareTracker <TPuzzle>?tracker))
     {
         // No solutions.
         return(new SolveStats());
     }
     return(_TryAllSolutions(tracker !, validateUniquenessOnly, cancellationToken));
 }