private void AddInternalWalls(List <Wall> walls) { var random = new Random(); const int minWallLength = 5; for (int i = 0; i < this.Arena.ArenaOptions.InteriorWalls; i++) { bool wallOrientationIsHorizontal = random.Next(0, 2) < 1; bool wallDoesMove = i < this.Arena.ArenaOptions.MovingWalls; int maxFreeSpace = wallOrientationIsHorizontal ? this.Arena.Width : this.Arena.Height; int wallLength = random.Next(minWallLength, maxFreeSpace - 20); //var spaceBetweenWallStartAndBoundary = random.Next(0, maxFreeSpace); int spaceBetweenWallStartAndBoundary = (maxFreeSpace - wallLength) / 2; int freeSpaceForMovement = maxFreeSpace - wallLength; //to make the walls appear symmetrical, I'm assuming that this only needs to be horizontal symmetry, not vertical... //otherwise the walls would only ever be located in the exact middle of the arena //also check if arena size is odd or even, if odd then make walls odd length, otherwise make even var thisWall = new Wall(); var mirWall = new Wall(); int xStart = random.Next(0, this.Arena.Width); int xOffset = wallOrientationIsHorizontal ? 1 : 0; int yStart = random.Next(0, this.Arena.Height); int yOffset = wallOrientationIsHorizontal ? 0 : 1; List <Position> safeWallPositions = GetPlayerSafeWallPositions(this.Players, new Position(xStart, yStart), wallLength, xOffset, yOffset); thisWall.AddRange(safeWallPositions); if (wallDoesMove) { const int wallSpeed = 1; // just in case we want to make this configurable in the future bool moveDirectionIsHorizontal = random.Next(0, 2) < 1; thisWall.MovementCycle = random.Next(5, Math.Max(5, freeSpaceForMovement - spaceBetweenWallStartAndBoundary)); thisWall.MovementTransform = moveDirectionIsHorizontal ? new Position(wallSpeed, 0) : new Position(0, wallSpeed); } walls.Add(thisWall); } }