コード例 #1
0
        public static void Test4()
        {
            int size = 16384;

            var alg  = new AlgorithmBacktrack();
            var w    = Stopwatch.StartNew();
            var maze = alg.Generate <BitArreintjeFastInnerMap, NetRandom>(size, size, 1337, null);

            Console.WriteLine($"Generation time: {w.Elapsed}");

            w.Restart();
            var result = MazeVerifier.IsPerfectMaze(maze);

            Console.WriteLine($"Perfect maze verification time: {w.Elapsed}");
            Console.WriteLine($"Is our maze perfect?: {result}");
        }
コード例 #2
0
            public void GeneratesAPerfectMaze()
            {
                //Arrange
                var generator = new AlgorithmBacktrack();

                long current    = 0;
                long total      = 0;
                var  mazeAction = new Action <int, int, long, long>((x, y, cur, tot) =>
                {
                    current = cur;
                    total   = tot;
                });

                //Act
                var map = generator.Generate <BitArreintjeFastInnerMap, NetRandom>(128, 128, mazeAction);

                Assert.True(MazeVerifier.IsPerfectMaze(map));
            }
コード例 #3
0
        public static void Test6()
        {
            int size = 4096;

            var alg  = new AlgorithmKruskal();
            var w    = Stopwatch.StartNew();
            var maze = alg.Generate <BitArreintjeFastInnerMap, NetRandom>(size, size, 1337, null);

            Console.WriteLine($"Generation time: {w.Elapsed}");

            w.Restart();
            var result = MazeVerifier.IsPerfectMaze(maze);

            Console.WriteLine($"Perfect maze verification time: {w.Elapsed}");
            Console.WriteLine($"Is our maze perfect?: {result}");

            using (var fs = new FileStream("KruskalMaze.png", FileMode.Create))
            {
                WithoutPath.MazeToImage(maze, fs);
            }
        }