Exemple #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);
        }
Exemple #2
0
        static void PolarGrid(int size)
        {
            Random    random = new Random();
            int       seed   = random.Next(int.MinValue, int.MaxValue);
            PolarGrid grid   = new PolarGrid(size, seed);

            Houstons.CreateMaze <PolarGrid, PolarCell>(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();
        }