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); }
private Maze GetMaze(int width, int height, Algorithms algorithm) { switch (algorithm) { case Algorithms.AldousBroderAvoidLinks: return(AldousBroderAvoidLinks.Create(height, width)); case Algorithms.AldousBroder: return(AldousBroder.Create(height, width)); case Algorithms.AldousBroderWilson: return(AldousBroderWilson.Create(height, width)); case Algorithms.BinaryTree: return(BinaryTree.Create(height, width)); case Algorithms.Sidewinder: return(Sidewinder.Create(height, width)); case Algorithms.Wilson: return(Wilson.Create(height, width)); case Algorithms.WilsonJb: return(WilsonJb.Create(height, width)); } throw new Exception($"Cannot get maze for algorithm '{algorithm}'"); }
public void TestAldousBroderColored() { var coloredGrid = new ColoredGrid(25, 25); AldousBroder.On(coloredGrid); coloredGrid.Distances = coloredGrid.GetCenterCell().Distances; coloredGrid.ToBitmap().Save("aldousbroder-colored.png"); }
private static void ColorizeThetaMazes() { var grid = new ColoredPolarGrid(100); BinaryTree.Maze(grid); var start = grid[0, 0]; grid.Distances = start.Distances; var img = grid.ToImg(25); img.Save("binaryTheta.png"); grid = new ColoredPolarGrid(100); Sidewinder.Maze(grid); start = grid[0, 0]; grid.Distances = start.Distances; img = grid.ToImg(25); img.Save("sidewinderTheta.png"); grid = new ColoredPolarGrid(100); AldousBroder.Maze(grid); start = grid[0, 0]; grid.Distances = start.Distances; img = grid.ToImg(25); img.Save("aldousBroderTheta.png"); grid = new ColoredPolarGrid(100); HuntAndKill.Maze(grid); start = grid[0, 0]; grid.Distances = start.Distances; img = grid.ToImg(25); img.Save("huntAndKillTheta.png"); grid = new ColoredPolarGrid(100); RecursiveBacktracker.Maze(grid, startAt: null); start = grid[0, 0]; grid.Distances = start.Distances; img = grid.ToImg(25); img.Save("recursiveBacktrackerTheta.png"); grid = new ColoredPolarGrid(100); Wilsons.Maze(grid); start = grid[0, 0]; grid.Distances = start.Distances; img = grid.ToImg(25); img.Save("wilsonsTheta.png"); Process.Start("binaryTheta.png"); Process.Start("sidewinderTheta.png"); Process.Start("aldousBroderTheta.png"); Process.Start("huntAndKillTheta.png"); Process.Start("recursiveBacktrackerTheta.png"); Process.Start("wilsonsTheta.png"); }
protected override void UpdateAlgorithm() { switch (algorithmType) { case Algo.BinaryTree: MyGrid = new BinaryTree(width, height); break; case Algo.SideWinder: MyGrid = new SideWinder(width, height); break; case Algo.AldousBroder: MyGrid = new AldousBroder(width, height); break; case Algo.HuntAndKill: MyGrid = new HuntAndKill(width, height); break; case Algo.RecursiveBacktracker: MyGrid = new RecursiveBacktracker(width, height); break; default: throw new ArgumentOutOfRangeException(); } IWallInstantiable wall; if (is3d) { wall = new WallPrefab3d { WallPrefab = wallPrefab3d } } ; else { wall = new WallPrefab2d { WallPrefab = wallPrefab2d } }; GridRenderer.Instance.SetGrid(MyGrid).ParentToTransform(parent).RenderWithPrefab(wall); MyGrid.Execute(this); }
public void TestAldousBroder() { var grid = new Grid(5, 5); AldousBroder.On(grid).ToBitmap().Save("aldousbroder.png"); }