private bool RecordTechnique( List <TechniqueInfo> steps, TechniqueInfo step, IReadOnlyGrid grid, Grid cloneation, Stopwatch stopwatch, IBag <IReadOnlyGrid> stepGrids, [NotNullWhen(true)] out AnalysisResult?result) { bool needAdd = false; foreach (var(t, c, d) in step.Conclusions) { switch (t) { case Assignment when cloneation.GetStatus(c) == CellStatus.Empty: case Elimination when cloneation.Exists(c, d) is true: { needAdd = true; goto Label_Determine; } } } Label_Determine: if (needAdd) { stepGrids.Add(cloneation.Clone()); step.ApplyTo(cloneation); steps.Add(step); if (cloneation.HasSolved) { result = new AnalysisResult( puzzle: grid, solverName: SolverName, hasSolved: true, solution: cloneation, elapsedTime: stopwatch.Elapsed, solvingList: steps, additional: null, stepGrids); return(true); } } result = null; return(false); }
/// <summary> /// To record the current technique step. /// </summary> /// <param name="steps">The steps have been found.</param> /// <param name="step">The current step.</param> /// <param name="cloneation">The cloneation of the grid.</param> /// <returns>A <see cref="bool"/> value.</returns> private bool RecordTechnique(ICollection <TechniqueInfo> steps, TechniqueInfo step, Grid cloneation) { foreach (var conclusion in step.Conclusions) { switch (conclusion.ConclusionType) { case Assignment when cloneation.GetStatus(conclusion.CellOffset) == Empty: case Elimination when cloneation.Exists(conclusion.CellOffset, conclusion.Digit) is true: { step.ApplyTo(cloneation); steps.Add(step); return(cloneation.HasSolved); } } } return(false); }