solveDeeply method
Gets the Solution
s as much as possible until the
minimum number of moves is reached or the timeout
is exceeded.
Implementation
Stream<Solution> solveDeeply(
Cube cube, {
Duration timeout = defaultTimeout,
}) async* {
var maxDepth = Solver.defaultMaxDepth;
final solutions = <Solution>{};
final sw = Stopwatch()..start();
while (sw.elapsed < timeout) {
final s = solve(
cube,
maxDepth: maxDepth,
timeout: timeout - sw.elapsed,
);
if (maxDepth > 0 && s != null && s.isNotEmpty) {
if (!solutions.contains(s)) {
solutions.add(s);
yield Solution(algorithm: s.algorithm, elapsedTime: sw.elapsed);
maxDepth = s.length - 1;
} else {
maxDepth--;
}
} else {
break;
}
}
}