Exemple #1
0
        static void Main(string[] args)
        {
            grid = new Grid();

            ParseCommandLine(args);
            

            if (!string.IsNullOrEmpty(puzzleFile))
            {
                grid = new Grid(DeserializeXmlPuzzle( OpenPuzzleFile(puzzleFile)));
            }
            else
            {
                grid = new Grid(DeserializeXmlPuzzle( OpenPuzzleFile(@"../../../xmlPuzzles/MxNpuzzleInternet2.xml")));
            }
            Console.WriteLine(grid.ToString());

            var watch = System.Diagnostics.Stopwatch.StartNew();

            grid.Solve();

            watch.Stop();
            Console.WriteLine("Milliseconds elapsed: " + watch.ElapsedMilliseconds);

            Console.Write("Program ran with these args: ");
            foreach (var arg in args)
            {
                Console.Write(arg + " ");
            }

            Console.ReadLine();
        }
Exemple #2
0
        private void solveButton_Click(object sender, EventArgs e)
        {
            if (CountGrid(GetGrid()) < 10)
            {
                MessageBox.Show("Please fill in atleast 10 fields. The program would run with less but would take an extremely long time", "Too few inputs", MessageBoxButtons.OK);
                return;
            }
            Stopwatch sw = new Stopwatch();

            sw.Start();
            Grid grid = new Grid(GetGrid(), parallelCheckBox.Checked);

            grid.Solve();

            setGrid(Grid.currentGrid);

            if (!Grid.IsValidGrid(Grid.currentGrid))
            {
                solved = grid.BruteForceSolve();
                if (solved.Count > 0)
                {
                    setGrid(solved[0]);
                    if (solved.Count > 1)
                    {
                        NextButton.Enabled = true;
                    }
                    index = 0;
                }

                CountLabel.Text = solved.Count.ToString();
            }
            else
            {
                CountLabel.Text = "1";
            }
            sw.Stop();
            timeLabel.Text = sw.Elapsed.ToString();
        }