Example #1
0
        private static void AssertIsSolved(SudokuPuzzle puzzle, SudokuPuzzle solution)
        {
            // Pre-Assert
            Assert.AreNotEqual(0, puzzle.RemainingPieces);

            // Act
            puzzle.Solve();

            // Assert
            Assert.AreEqual(0, puzzle.RemainingPieces);
            Assert.AreEqual(true, IsPuzzleValid(puzzle));

            Assert.AreEqual(0, solution.RemainingPieces);
            Assert.AreEqual(true, IsPuzzleValid(solution));

            var ps = solution.GetPuzzle();
            var pp = puzzle.GetPuzzle();

            for (int i = 0; i < 9; ++i)
            {
                for (int k = 0; k < 9; ++k)
                {
                    Assert.AreEqual(pp[i, k].Value, ps[i, k].Value);
                    Assert.AreEqual(true, ps[i, k].PossibleValues == null);
                    Assert.AreEqual(true, pp[i, k].PossibleValues == null);
                }
            }
        }
Example #2
0
        public void RunTestStuff()
        {
            string       testfile = Directory.GetParent(Application.StartupPath).Parent.Parent.FullName + "\\Boards\\Board.csv";
            SudokuPuzzle newPuz   = new SudokuPuzzle(SudokuPuzzle.GetPuzzle(testfile));

            ChangePuzzle(newPuz);
            //btnMostDiff.PerformClick();
            //btnCellBreak.PerformClick();
        }
Example #3
0
        private void btnMostDiff_Click(object sender, EventArgs e)
        {
            string filePath = @".\Boards\GEOboard.csv";

            filePath = @".\Boards\MostDifficult.csv";
            SudokuPuzzle newPuz = new SudokuPuzzle(SudokuPuzzle.GetPuzzle(filePath));

            //SudokuPuzzle newPuz = new SudokuPuzzle(SudokuSolver.Program.GetPuzzle(10));

            ChangePuzzle(newPuz);
        }
Example #4
0
        private void btnLoadFile_Click(object sender, EventArgs e)
        {
            OpenFileDialog openFileDialog1 = new OpenFileDialog();

            openFileDialog1.InitialDirectory = Directory.GetParent(Application.StartupPath).Parent.Parent.FullName + "\\Boards";

            if (openFileDialog1.ShowDialog() == DialogResult.OK)
            {
                try
                {
                    SudokuPuzzle newPuz = new SudokuPuzzle(SudokuPuzzle.GetPuzzle(openFileDialog1.FileName));
                    ChangePuzzle(newPuz);
                }
                catch (Exception ex)
                {
                    MessageBox.Show("Error: Could not read file from disk. Original error: " + ex.Message);
                }
            }
        }