コード例 #1
0
        public void SolvePuzzles()
        {
            Puzzle puzzle = null;
            List<char[]> OriginalCellValues = null;
            StrategySolver solver = new StrategySolver();
            solver.Strategies.Add(new Comprehensive());

            PuzzleInitializer initializer = new FileInitializer();
            initializer.PuzzleFilePath = Server.MapPath("~") + @"..\puzzles\";
            initializer.InitializePuzzle(out puzzle);

            if (puzzle.ErrorMessage == null)
            {
                OriginalCellValues = GetPuzzleCellValues(puzzle);
                solver.Solve(puzzle);
            }
            if(puzzle.ErrorMessage != null)
            {
                ReportError(puzzle.ErrorMessage);
            }
            else
            {
                List<char[]> SolvedCellValues = GetPuzzleCellValues(puzzle);
                WritePuzzle(puzzle, OriginalCellValues, SolvedCellValues);
            }
        }
コード例 #2
0
        static void Main(string[] args)
        {
            StrategySolver solver = new StrategySolver();

            // TODO: (DONE) Add strategies
            solver.Strategies.Add(new Comprehensive());

            // TODO: (DONE) Initialize puzzle from file
            Puzzle puzzle = null;
            PuzzleInitializer initializer = new FileInitializer();
            initializer.InitializePuzzle(out puzzle);

            if (puzzle.ErrorMessage == null)
            {
                Console.WriteLine(puzzle.ToString().Replace('0', ' '));
                solver.Solve(puzzle);
            }
            if (puzzle.ErrorMessage != null)
            {
                Console.WriteLine(puzzle.ErrorMessage);
            }
            else
            {
                Console.Write(puzzle);
            }
            Console.WriteLine();
            Console.WriteLine("Press <ENTER> to continue.");
            Console.ReadLine();
        }
コード例 #3
0
        static void Main(string[] args)
        {
            StrategySolver solver = new StrategySolver();
            // TODO: Add strategies

            // TODO: Initialize puzzle from file
            Puzzle puzzle = null;

            solver.Solve(puzzle);
            Console.Write(puzzle);

            Console.WriteLine();
            Console.WriteLine("Press <ENTER> to continue.");
            Console.ReadLine();
        }