Beispiel #1
0
        public ActionResult MazeDynamicPathSeedPart(int seed, int width, int height, int xPart, int yPart, int partWidth, int partHeight)
        {
            var alg = new AlgorithmDivisionDynamicWithPath();

            var w   = Stopwatch.StartNew();
            var map = alg.Generate <UndefinedInnerMap, NetRandom>(width, height, seed, null);
            var mazeGenerationTime = w.Elapsed;

            w.Restart();
            using (var memoryStream = new MemoryStream())
            {
                WithPath.SaveMazeAsImageDeluxePngWithParts(map, map.PathData, xPart, yPart, partWidth, partHeight, memoryStream);
                var toImageTime = w.Elapsed;

                Console.WriteLine($"Maze generation time: {mazeGenerationTime} To image time: {toImageTime}");

                var data = memoryStream.ToArray();
                return(File(data, "image/png"));
            }
        }
        public static void Test7()
        {
            int size = 64;

            var alg  = new AlgorithmDivisionDynamicWithPath();
            var maze = alg.GenerateWithPath <BitArreintjeFastInnerMap, NetRandom>(size, size, 1337, null);

            using (var fs = new FileStream("DivisionDynamicWithPath.png", FileMode.Create))
            {
                WithPath.SaveMazeAsImageDeluxePng(maze, maze.PathData, fs);
            }

            //var alg = new AlgorithmDivisionDynamic();
            //var maze = alg.Generate<UndefinedInnerMap, NetRandom>(size, size, null);

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