Exemplo n.º 1
0
        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();
            }
        }
Exemplo n.º 2
0
 public GradientDescentSolver(SudokuGrid initialGrid)
     : base(initialGrid)
 {
     _solvedGrid = initialGrid; // start with the initial grid
     _solvedGrid.Randomize();
 }