コード例 #1
0
        private Maze GetMaze(int width, int height, Algorithms algorithm)
        {
            switch (algorithm)
            {
            case Algorithms.AldousBroderAvoidLinks:
                return(AldousBroderAvoidLinks.Create(height, width));

            case Algorithms.AldousBroder:
                return(AldousBroder.Create(height, width));

            case Algorithms.AldousBroderWilson:
                return(AldousBroderWilson.Create(height, width));

            case Algorithms.BinaryTree:
                return(BinaryTree.Create(height, width));

            case Algorithms.Sidewinder:
                return(Sidewinder.Create(height, width));

            case Algorithms.Wilson:
                return(Wilson.Create(height, width));

            case Algorithms.WilsonJb:
                return(WilsonJb.Create(height, width));
            }

            throw new Exception($"Cannot get maze for algorithm '{algorithm}'");
        }
コード例 #2
0
        private static void TimeAbwMazeCreation()
        {
            int  cells     = 50;
            int  nTests    = 10;
            long totalTime = 0;

            Enumerable.Range(0, nTests).ForEach(n => {
                Stopwatch sw = Stopwatch.StartNew();
                AldousBroderWilson.Create(cells, cells);
                totalTime += sw.ElapsedMilliseconds;
            });
            Debug.WriteLine(totalTime / nTests);
        }