Exemplo n.º 1
0
        public static void Main(string[] args)
        {
            //var solver = new DepthFirstSearchSolver(NUM_ROPES, ROPE_BURN_TIME);
            var solver = new BreadthFirstSearchSolver(NUM_ROPES, ROPE_BURN_TIME);
            var allKnownTimesWithInstructions = solver.Solve();

            var summary = FormatUtilities.GetSummary(allKnownTimesWithInstructions, NUM_ROPES, ROPE_BURN_TIME);

            Console.WriteLine(summary);

            Console.WriteLine(Environment.NewLine + "Press any key for detailed instructions...");
            Console.ReadKey();

            foreach (var knownTime in allKnownTimesWithInstructions)
            {
                var humanReadableInstructions = FormatUtilities.GetHumanReadableInstructions(knownTime.Key, knownTime.Value);
                foreach (var humanReadableInstruction in humanReadableInstructions)
                {
                    Console.WriteLine(humanReadableInstruction);
                }

                Console.WriteLine();
            }
            Console.WriteLine(Environment.NewLine + "Press any key to end...");
            Console.ReadKey();
        }
Exemplo n.º 2
0
        public void TestFindingDirectionsBreadthFirstSearchRomania()
        {
            var solver  = new BreadthFirstSearchSolver <FindingDirectionsState>();
            var problem = GetRomaniaProblem();

            TestSolver(solver, problem, 450);
            // note this is not optimal in fewest number of edges, not cost
        }
Exemplo n.º 3
0
        public void TestNPuzzleBreadthFirstSearch()
        {
            var solver  = new BreadthFirstSearchSolver <NPuzzle>();
            var problem = new NPuzzleProblem(3, 3, "8 6 7 2 5 4 3 0 1");

            TestSolver(solver, problem, 27);
            // cannot really solve larger problems with this method
        }
Exemplo n.º 4
0
        static void Main(string[] args)
        {
            var puzzle   = new StarSunPuzzle();
            var solver   = new BreadthFirstSearchSolver();
            var solution = solver.Solve(puzzle);

            Console.WriteLine(puzzle);
            foreach (var(pos, dir) in solution)
            {
                Thread.Sleep(1000);
                puzzle.Move(pos, dir);
                Console.Clear();
                Console.WriteLine(puzzle);
            }
        }