private void GradientDescent() { if (_solverStopwatch.Elapsed.TotalSeconds > 60) { throw new InvalidOperationException("Could not solve in 60 seconds"); } foreach (Node node in _solvedGrid.EditableGrid) { DoDescent(node); } // Didn't solve, try again if (PerformEvaluationFunction() > 0) { _iterations++; _solvedGrid.Randomize(); GradientDescent(); } }
public GradientDescentSolver(SudokuGrid initialGrid) : base(initialGrid) { _solvedGrid = initialGrid; // start with the initial grid _solvedGrid.Randomize(); }