Example #1
0
        public MainWindow()
        {
            InitializeComponent();

            InitializeEngine();
            InitializeGrid();

            var puzzle = PredefinedPuzzles.GetPuzzleByGroupAndNumber("nakedpairs", 1);

            //var puzzle = PredefinedPuzzles.EmptyPuzzle;
            //var puzzle = PredefinedPuzzles.GetRandomPuzzle();
            engine.LoadPuzzle(puzzle);
            PuzzleName.Content = puzzle.Name;
            PopulateUIWithValues();
            DrawAllPossibles();
        }
Example #2
0
        public MainPage()
        {
            InitializeComponent();

            InitializeEngine();
            InitializeGrid();

            //var puzzle = PredefinedPuzzles.GetPuzzleByGroupAndNumber("extremesudoku.info", 3);
            var puzzle = PredefinedPuzzles.EmptyPuzzle;

            //var puzzle = PredefinedPuzzles.GetRandomPuzzle();
            engine.LoadPuzzle(puzzle);
            PuzzleName.Text = puzzle.Name;
            PopulateUIWithValues();
            DrawAllPossibles();
        }
        private static void RunPuzzle(Puzzle puzzle, int maxExecution = 100)
        {
            var engine = new SolverEngine();

            //engine.WriteLog = (message) => { Console.WriteLine(message); };
            engine.LoadPuzzle(puzzle);

            long elapsed = engine.TrySolveToEnd();

            Console.WriteLine(puzzle.Name.PadRight(19) + " : " +
                              "e " + elapsed.ToString().PadRight(3) + ", " +
                              "g " + engine.GuessedMoves().ToString().PadRight(3) + ", " +
                              "u " + engine.Undos.ToString().PadRight(3));

            bool solved = engine.IsFullySolved();

            Assert.IsTrue(solved, "Could not solve puzzle " + puzzle.Name);
            Assert.LessOrEqual(elapsed, maxExecution, "Elapsed milliseconds must be less than " + maxExecution);
        }