Esempio n. 1
0
        public PuzzleGroup(string name, List<string> puzzleValues)
        {
            Name = name;
            Puzzles = new List<Puzzle>();

            int counter = 1;
            foreach (string puzzleValue in puzzleValues)
            {
                var puzzle = new Puzzle(puzzleValue) { Group = name, Name = name + counter };
                Puzzles.Add(puzzle);
                counter++;
            }
        }
        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);
        }
Esempio n. 3
0
        public void LoadPuzzle(Puzzle puzzle)
        {
            AnnulAllValues();
            AnnulAllPossibles();

            Array.Copy(puzzle.Values, values, puzzle.Values.Length);
        }
        private void GenerateRandomPuzzle_Click(object sender, RoutedEventArgs e)
        {
            var empty = PredefinedPuzzles.EmptyPuzzle;
            engine.LoadPuzzle(empty);
            engine.TrySolveToEnd();
            engine.ClearXMoves(50);

            var puzzle = new Puzzle(engine.CopyValues()) { Name = "Random " + Guid.NewGuid().ToString() };

            InitializeEngine();
            InitializeGrid();

            engine.LoadPuzzle(puzzle);
            PuzzleName.Content = puzzle.Name;
            PopulateUIWithValues();
            DrawAllPossibles();
        }