/// <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()); }
/// <summary> /// THis method will sent a random starting point /// in the maze and set it to 0 /// </summary> public void RandomStart() { Random rand = new Random(); int row = rand.Next(0, HEIGHT); int col = rand.Next(0, WIDTH); maze.SetCell(row, col, 0); maze.SetStartPoints(row, col); //This will start createing the maze using recursion Recursion(row, col); //This will set the end points of the maze maze.SetEndPoints(endRow, endCol); }