public void SelectNumber(int number) { _sudokuController.isSelectingNumber = false; var valid = _sudokuController.InputValue(this, number); numberSelector.SetActive(false); cell.value = number; RenderCell(valid); }
private void ContinueSolve(int pos) { print("Continuing the Solve"); for (var i = pos; i < _cells.Count; i++) { // Continue if this cell already has a value if (_cells[i].value != 0 || !_cells[i].editable) { Debug.Log($"Skipping Cell {_cells[i].row}:{_cells[i].column} - it is not editable."); continue; } Debug.Log($"Solving Cell {_cells[i].row}:{_cells[i].column}"); _currentCellPos = i; // Try each value for this empty cell var numbers = new List <int> { 1, 2, 3, 4, 5, 6, 7, 8, 9 }; if (numbers.Any(number => _sudokuController.InputValue(_cells[i].cellView, number))) { // UnityMainThreadDispatcher.Instance().Enqueue(() => _cells[i].cellView.RenderCell()); _cells[i].cellView.RenderCell(); Debug.Log($"{_cells[i].value} input in Cell {_cells[i].row}:{_cells[i].column}"); } // Backtrack if the Value in the Cell is still 0 at this point if (_cells[i].value != 0) { continue; } Debug.Log($"Cell {_cells[i].row}:{_cells[i].column} has no valid option\nStart Backtracking"); Backtrack(); break; } _sw.Stop(); Debug.Log( $"Completed the Sudoku in {_sw.ElapsedMilliseconds / 1000f} seconds\n" + $"Times Backtracked: {_timesBacktracked}"); }