コード例 #1
0
ファイル: Program.cs プロジェクト: AlanEmersic/Mazes-CSharp
        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);
        }
コード例 #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");
        }
コード例 #3
0
ファイル: Program.cs プロジェクト: AlanEmersic/Mazes-CSharp
        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();
        }
コード例 #4
0
ファイル: Program.cs プロジェクト: AlanEmersic/Mazes-CSharp
        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();
        }