protected void SolveButton_Click(object sender, EventArgs e)
        {
            //try
            //{
                Puzzle puzzle;
                if (!TestPuzzles.Puzzles.TryGetValue(PuzzleDropDown.Text, out puzzle))
                {
                    throw new InvalidPuzzleException("Select Valid Puzzle from list");
                }
                else
                {
                    PuzzleSolver solver = new PuzzleSolver(puzzle);
                    solver.Solve();

                    if (solver.Solve())
                    {
                        UpdateDisplay(puzzle);
                    }
                    else
                    {

                        //MessageBox.Show(solver.ErrorMessage);
                    }
                }
            //}
            //catch (InvalidPuzzleException ex)
            //{
            //     MessageBox.Show(ex.Message);
            //}
        }
示例#2
0
        public void TestMethod1()
        {
            PuzzleSolver solver = new PuzzleSolver(Puzzle);
            solver.Solve();
            int[,] expected = { { -1, 1, -1, 1, -1 }, { 1, 1, 1, 1, 1 }, { -1, 1, -1, 1, -1 }, { 1, 1, 1, 1, 1 }, { -1, 1, -1, 1, -1 } };

            foreach (var cell in Puzzle.Cells)
            {
                Assert.AreEqual(expected[cell.Key.X,cell.Key.Y], cell.Value);
            }
        }
示例#3
0
        private void testButton_Click(object sender, EventArgs e)
        {
            Puzzle puzzle;
            if (!testPuzzles.TryGetValue(chooseTest.Text, out puzzle))
            {
                MessageBox.Show("Please choose valid puzzle from the list");
            }
            else
            {
                PuzzleSolver solver = new PuzzleSolver(puzzle);
                solver.Solve();

                if (solver.Solve())
                {
                    UpdateDisplay(puzzle);
                }
                else
                {
                    MessageBox.Show(solver.ErrorMessage);
                    UpdateDisplay(puzzle);
                }
            }
        }
示例#4
0
        private void solveButton_Click(object sender, EventArgs e)
        {
            var rowString = "";
            foreach (var box in rowTextBoxs)
            {
                rowString += box.Value.Text + ";";
            }
            var colString = "";
            foreach (var box in rowTextBoxs)
            {
                colString += box.Value.Text + ";";
            }

            var puzzle = PuzzleFactory.Instance().MakePuzzle(numberOfRows, numberOfColumns, rowString, colString);

            PuzzleSolver solver = new PuzzleSolver(puzzle);
            solver.Solve();

            if (solver.Solve())
            {
                UpdateDisplay(puzzle);
            }
            else
            {
                MessageBox.Show(solver.ErrorMessage);
            }
        }