I use a diamond-square algorithm to generate random terrain. It works great, except that I get these large cone shapes protruding from or into the relief. The problem seems to be that from time to time the point gets too high or too low.
Here is a picture of the problem

And it can be better seen when I set the smoothness to the highest level 
And here is my code -
private void CreateHeights() { if (cbUseLand.Checked == false) return; int Size = Convert.ToInt32(System.Math.Pow(2, int.Parse(tbDetail.Text)) + 1), SideLength = Size - 1, d = 1025 / (Size - 1), HalfSide; Heights = new Point3D[Size, Size]; float r = float.Parse(tbHeight.Text), Roughness = float.Parse(RoughnessBox.Text); //seeding all the points for (int x = 0; x < Size; x++) for (int y = 0; y < Size; y++) Heights[x, y] = Make3DPoint(x * d, 740, y * d); while (SideLength >= 2) { HalfSide = SideLength / 2; for (int x = 0; x < Size - 1; x = x + SideLength) { for (int y = 0; y < Size - 1; y = y + SideLength) { Heights[x + HalfSide, y + HalfSide].y = (Heights[x, y].y + Heights[x + SideLength, y].y + Heights[x, y + SideLength].y + Heights[x + SideLength, y + SideLength].y) / 4 - r + ((float)(random.NextDouble() * r) * 2); } } for (int x = 0; x < Size - 1; x = x + SideLength) { for (int y = 0; y < Size - 1; y = y + SideLength) { if (y != 0) Heights[x + HalfSide, y].y = (Heights[x, y].y + Heights[x + SideLength, y].y + Heights[x + HalfSide, y + HalfSide].y + Heights[x + HalfSide, y - HalfSide].y) / 4 - r + ((float)(random.NextDouble() * r) * 2); if (x != 0) Heights[x, y + HalfSide].y = (Heights[x, y].y + Heights[x, y + SideLength].y + Heights[x + HalfSide, y + HalfSide].y + Heights[x - HalfSide, y + HalfSide].y) / 4 - r + ((float)(random.NextDouble() * r) * 2); } } SideLength = SideLength / 2; r = r / Roughness; } }
source share