/// <summary> /// This method will create the maze using the DFS /// algorithm /// </summary> /// <param name="createable">A creatable maze</param> public void create(ICreateable <T> createable) { this.maze = createable.GetMaze(); this.HEIGHT = createable.GetHeight(); this.WIDTH = createable.GetWidth(); RandomStart(); }
/// <summary> /// Main Method that will created a maze using Prims Algorithm </summary> /// <param name="createable">Maze</param> public void create(ICreateable <T> createable) { this.maze = createable.GetMaze(); this.height = createable.GetHeight(); this.width = createable.GetWidth(); List <Node <T> > primList = new List <Node <T> >(); rand = new Random(); //Sets a random Starting Point int rRow = rand.Next(height); int rCol = rand.Next(width); maze.GetNode(rRow, rCol).SetValue(0); maze.SetStartPoints(rRow, rCol); //Adds Node to the Prims List primList.Add(maze.GetNode(rRow, rCol)); //Will run as long as the List is not empty while (primList.Count > 0) { primList = primList.Distinct().ToList(); this.getNeighbors(primList); } //Sets the end Point of the maze this.maze.SetEndPoints(last.GetRow(), last.GetCol()); }