Esempio n. 1
0
        static G RandomAlgorithm <G, T>(Grid grid, Algorithm algorithm) where G : Grid where T : Cell
        {
            switch (algorithm)
            {
            case Algorithm.AldousBroder: return(AldousBroder.CreateMaze <G, T>(grid as G));

            case Algorithm.BinaryTree: return(BinaryTree.CreateMaze(grid) as G);

            case Algorithm.HuntAndKill: return(HuntAndKill.CreateMaze <G, T>(grid as G));

            case Algorithm.RecursiveBacktracker: return(RecursiveBacktracker.CreateMaze <G, T>(grid as G));

            case Algorithm.Sidewinder: return(Sidewinder.CreateMaze(grid) as G);

            case Algorithm.Wilsons: return(Wilsons.CreateMaze <G, T>(grid as G));

            case Algorithm.Kruskals: return(Kruskals.CreateMaze(grid) as G);

            case Algorithm.Prims: return(Prims.CreateMaze <G, T>(grid as G));

            case Algorithm.TruePrims: return(TruePrims.CreateMaze <G, T>(grid as G));

            case Algorithm.GrowingTree: return(GrowingTree.CreateMaze <G, T>(grid as G));

            case Algorithm.RecursiveDivision: return(RecursiveDivision.CreateMaze(grid) as G);

            case Algorithm.Ellers: return(Ellers.CreateMaze(grid) as G);

            case Algorithm.Houstons: return(Houstons.CreateMaze <G, T>(grid as G));
            }
            return(null);
        }
Esempio n. 2
0
        private static void BuildPolar()
        {
            Console.WriteLine("Polar");

            var grid = PolarGrid.CreatePolarGrid(40);

            var mazeBuilder = new RecursiveBacktracker();

            mazeBuilder.Build(grid);

            var distances = Distances.Build(grid.GetCell(0, 0));

            var gd     = GridDisplayFactory.GetDisplayForGrid(grid);
            var bitmap = gd.MakeImage(distances);

            bitmap.Save("Polar.png", ImageFormat.Png);
            Console.WriteLine("Done");
        }
Esempio n. 3
0
        static void TriangleGrid(int rows, int cols)
        {
            Random       random = new Random();
            int          seed   = random.Next(int.MinValue, int.MaxValue);
            TriangleGrid grid   = new TriangleGrid(rows, cols, seed);

            RecursiveBacktracker.CreateMaze <TriangleGrid, TriangleCell>(grid);

            Bitmap img  = grid.ToPNG(50);
            string name = "Maze.png";

            img.Save(name);

            Process process = new Process();

            process.StartInfo.FileName = name;
            process.Start();
            process.Close();
        }
Esempio n. 4
0
        static void HexGrid(int size)
        {
            Random  random = new Random();
            int     seed   = random.Next(int.MinValue, int.MaxValue);
            HexGrid grid   = new HexGrid(size, size, seed);

            RecursiveBacktracker.CreateMaze <HexGrid, HexCell>(grid);

            Bitmap img  = grid.ToPNG(50);
            string name = "Maze.png";

            img.Save(name);

            Process process = new Process();

            process.StartInfo.FileName = name;
            process.Start();
            process.Close();
        }