コード例 #1
0
ファイル: Program.cs プロジェクト: darnetgit/Tutorial
        private static void testSearchAlgorithms()
        {
            ArrayList s = new ArrayList();

            s.Add(5);
            s.Add(5);
            s.Add(4);
            MyMaze3dGenerator mg   = new MyMaze3dGenerator();
            AMaze             maze = mg.generate(s);

            maze.Print();
            Console.WriteLine("DFS solution path:");
            SearchableMaze3d sm    = new SearchableMaze3d((maze as Maze3d));
            DepthFirstSearch ds    = new DepthFirstSearch();
            Solution         dssol = ds.Solve(sm);

            dssol.PrintSolution();
            Console.WriteLine("-------------------------------------------------------");
            Console.WriteLine("for BFS solution press any key");
            Console.ReadKey();
            Console.WriteLine("BFS solution path:");
            BreadthFirstSearch bs    = new BreadthFirstSearch();
            Solution           bssol = bs.Solve(sm);

            bssol.PrintSolution();
            Console.WriteLine("-------------------------------------------------------");
            Console.WriteLine("for further information about DFS solution press any key");
            Console.ReadKey();
            Console.WriteLine("num of nodes developed in DFS: " + ds.getNumberOfNodes());
            Console.WriteLine("time it took to find solution(ms) in DFS: " + ds.GetSolvingTime());
            Console.WriteLine();
            Console.WriteLine("for further information about BFS solution press any key");
            Console.ReadKey();
            Console.WriteLine();
            Console.WriteLine("num of nodes developed in BFS: " + bs.getNumberOfNodes());
            Console.WriteLine("time it took to find solution(ms) in BFS: " + bs.GetSolvingTime());
        }