Exemple #1
0
        static void ABFS(string input, SearchMode mode)
        {
            var nodeFactory = new AStarNodeFactory(new PathRemaninerPriceEstimator());//new SimpleRemainerPriceEstimator());
            var expander    = new DummyNodeExpander <AStarNode <State> >(nodeFactory);
            var searcher    = new AStarBreathFirstSearch(expander, mode);
            var parser      = new Parser(input);

            var results = searcher.Search(nodeFactory.CreateNode(null, new InitAction(parser)));

            foreach (var res in results)
            {
                Console.WriteLine($"==Solution==");
                Console.WriteLine($"Result:\r\n{res.Dump()}");

                Console.WriteLine($"==Solution stats==");
                Console.WriteLine($"Depth: {res.Depth}");
                Console.WriteLine($"Price: {res.PathPrice}");
                Console.WriteLine($"PriceEstimate: {res.GoalPriceEstimate}");

                Console.WriteLine($"==Searcher stats==");
                Console.WriteLine($"ExpandedNodes: {searcher.ExpandedNodesStat}");
                Console.WriteLine($"MaxDepth: {searcher.MaxDepthStat}");
                break;
                if (Console.ReadKey(false).Key == ConsoleKey.Enter)
                {
                    Console.WriteLine($"Aborting search...");
                    break;
                }
                Console.WriteLine($"Searching next solution: =>>>>>>>>>>>>>>>>>>>>>>");
            }
        }
Exemple #2
0
        static void BFS(string input, SearchMode mode)
        {
            var nodeFactory = new DefaultNodeFactory();
            var expander    = new DummyNodeExpander <Node <State> >(nodeFactory);
            var searcher    = new BreathFirstSearch(expander, mode);
            var parser      = new Parser(input);

            var results = searcher.Search(nodeFactory.CreateNode(null, new InitAction(parser)));
            var res     = results.First();

            Console.WriteLine($"Result:\r\n{res.Dump()}");
            Console.WriteLine($"MaxDepth: {searcher.MaxDepthStat}");
            Console.WriteLine($"ExpandedNodes: {searcher.ExpandedNodesStat}");
        }