Esempio n. 1
0
        //Auto cell validation for beginner difficulty
        public void AutoValidateForBeginner()
        {
            string value, column, row;

            value  = SudokuMatrix[CurrentRow, CurrentColumn].ToString();
            column = (CurrentColumn + 1).ToString();
            row    = (CurrentRow + 1).ToString();
            if (SudokuChecker.ValidateCell(SudokuMatrix, CurrentRow, CurrentColumn, SudokuMatrix[CurrentRow, CurrentColumn]) == false)
            {
                AddInstructorText("Value " + value + " of [" + row + ":" + column + "] is not legit. Please try again");
            }
            else
            {
                AddInstructorText("Value " + value + " of [" + row + ":" + column + "] is legit. Hurray");
            }
        }
Esempio n. 2
0
 //Validate if player has completed the game
 public void ValidateGame()
 //If SudokuChecker function return true, then player win the game
 {
     if (SudokuChecker.SudokuValidation(SudokuMatrix) == true)
     {
         SudokuTimer.Stop();
         TriggerButton.Enabled  = false;
         SuggestButton.Enabled  = false;
         ValidateButton.Enabled = false;
         SolveButton.Enabled    = false;
         MessageBox.Show(" Congratulation you have completed the game \n Please start a new game", "Confirmation", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
     else
     {
         MessageBox.Show(" Sorry, the game is not completed yet", "Confirmation", MessageBoxButtons.OK, MessageBoxIcon.Warning);
     }
 }
Esempio n. 3
0
 //Suggest solution for current cell
 public void SuggestCell()
 {
     if (SudokuChecker.SudokuSolver(SudokuTempSolution, 0, 0))
     {
         if (SudokuMatrix[CurrentRow, CurrentColumn] != SudokuTempSolution[CurrentRow, CurrentColumn])
         {
             string SuggestNumber = SudokuTempSolution[CurrentRow, CurrentColumn].ToString();
             AddInstructorText("You should fill " + SuggestNumber + " in the cell [" + (CurrentColumn + 1).ToString() + ":" + (CurrentRow + 1).ToString() + "]");
         }
         else
         {
             AddInstructorText("You have filled the right number");
         }
     }
     else
     {
         AddInstructorText("Cannot suggest due to invalid value existed");
     }
 }
Esempio n. 4
0
 //Solve the game if player give up
 public void SolveGame()
 {
     if (SudokuChecker.SudokuSolver(SudokuTempSolution, 0, 0))
     {
         MessageBox.Show(" Resolve successful \n Timer will be reseted \n Please start a new game", "Error", MessageBoxButtons.OK, MessageBoxIcon.Information);
         SudokuTimer.Stop();
         hour                   = 0; minute = 0; second = 0;
         TimeCounter.Text       = string.Format("{0}:{1}:{2}", hour.ToString().PadLeft(2, '0'), minute.ToString().PadLeft(2, '0'), second.ToString().PadLeft(2, '0'));
         TriggerButton.Enabled  = false;
         SuggestButton.Enabled  = false;
         ValidateButton.Enabled = false;
         SolveButton.Enabled    = false;
         Copy(SudokuTempSolution, SudokuMatrix);
         ShowMatrix();
     }
     else
     {
         MessageBox.Show(" Cannot solve due to rule violation \n Please check again", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }