Ejemplo n.º 1
0
        public void TestGenerate1()
        {
            const int number = 10;

            int[][,] result = new int[number][, ];

            SudokuFounctionLibrary.generate(number, ref result);

            for (int i = 0; i < number; i++)
            {
                Assert.AreEqual(true, TestValid(result[i]));
            }
        }
Ejemplo n.º 2
0
        public void TestGenerateUnique()
        {
            int[][,] result = null;
            const int number = 1;
            const int lower  = 50;
            const int upper  = 55;
            const int size   = 9;

            int[] keys = new int[number];
            int[] digs = new int[number];
            SudokuFounctionLibrary.generate(number, lower, upper, true, ref result);

            // test
            for (int i = 0; i < number; i++)
            {
                int[,] puzzle = result[i];

                // 测试挖空数目
                int count = 0;

                for (int j = 0; j < size; j++)
                {
                    for (int k = 0; k < size; k++)
                    {
                        if (puzzle[j, k] == 0)
                        {
                            count++;
                        }
                    }
                }
                digs[i] = count;
                bool real     = (count <= upper && count >= lower);
                bool expected = true;

                Assert.AreEqual(expected, real);

                // 测试唯一解
                Solver s = new Solver(puzzle);
                s.Solve();
                real = s.IsUniqueSolution();

                //Assert.AreEqual(expected, real);

                /*Table t = new Table();
                 * t.creat(puzzle);
                 * keys[i] = t.solve();
                 * Assert.AreEqual(1, keys[i]);*/
            }
            //Assert.AreEqual(1, keys[0]);
            //Assert.AreEqual(true, digs[0] <= upper && digs[0] >= lower);
        }
Ejemplo n.º 3
0
        private void BeginGameButton_Click(object sender, RoutedEventArgs e)
        {
            if (EasyComboBoxItem.IsSelected)
            {
                mode = 1;
            }
            if (MediumComboBoxItem.IsSelected)
            {
                mode = 2;
            }
            if (HardComboBoxItem.IsSelected)
            {
                mode = 3;
            }

            SudokuFounctionLibrary.generate(1, mode, ref GUIpuzzle);

            NavigationWindow window = new NavigationWindow();

            window.Source = new Uri("Gaming.xaml", UriKind.Relative);
            window.Height = 750;
            window.Width  = 600;
            window.Show();
        }