private void DifficultyIncrease() //Removes parts of the walls creating more possible pathways with some leading to deadends { foreach (var child in _mazeGrid.MazeGrid) { var decisionToRemove = MathRandom.GetRandomNumber(0, 20); if (decisionToRemove == 5) { child.IsPath = true; } } }
private void CreateExitPoint() //Creates a random end point to the maze in the bottom right quadrant of the maze { var flag = true; var findMaze = (_maze.Length) - (_maze.Length / 4); while (flag) { var testX = MathRandom.GetRandomNumber(findMaze, (_maze.Length - 1)); var testY = MathRandom.GetRandomNumber(findMaze, (_maze.Length - 1)); if (_maze.MazeGrid.Exists(x => x.X == testX && x.Y == testY && x.IsPath)) { _finalCoords = new Mazepoints(testX, testY, true, false); flag = false; } } }
private static int[] RandomDirections() //Generates an array of directions that is used to decide the order in the Depth First Search switch statemnet { int[] randoms = new int[8]; for (int i = 0; i < randoms.Length; i++) { randoms[i] = i; } for (int i = randoms.Length; i > 1; i--) { int a = MathRandom.GetRandomNumber(0, i); int tmp = randoms[a]; randoms[a] = randoms[i - 1]; randoms[i - 1] = tmp; } return(randoms); }