# Seams appearing in Terrain after deformation

Hello guys,

I am working on an evolution project that deforms the terrain each generation and tries to adapt it to a creature. For example I’m trying to move a sphere through random mutation of the terrain to a certain spot. After a few mutations seams between patches appear as in this screenshot:

The basic rundown of the program is:
Attach the individual, evaluate the fitness, detach everything(terrain and creature) and then attach the next individual.

After all individuals are done I select a few individuals(clone them) and mutate them with the following code which is from TerrainTestModifyHeight with a bit of randomness.

[java]
float p = FastMath.nextRandomFloat();
if (p > strength) {
float locx = (FastMath.nextRandomFloat() * 64 * 2) - 64f;
float locz = (FastMath.nextRandomFloat() * 64 * 2) - 64f;
float radius = FastMath.nextRandomFloat() * 32 + 8;
float str = FastMath.nextRandomFloat() * (4.5f * 2) - 4.5f;
}
return terrain;
}

``````private static void adjustHeight(Vector3f loc, float radius, float height, TerrainQuad terrain) {
// offset it by radius because in the loop we iterate through 2 radii

float xStepAmount = terrain.getLocalScale().x;
float zStepAmount = terrain.getLocalScale().z;
List&lt;Vector2f&gt; locs = new ArrayList&lt;&gt;();
List&lt;Float&gt; heights = new ArrayList&lt;&gt;();

float locX = loc.x + (x * xStepAmount);
float locZ = loc.z + (z * zStepAmount);

// see if it is in the radius of the tool
float h = calculateHeight(radius, height, locX - loc.x, locZ - loc.z);
}
}
}

terrain.updateModelBound();
}[/java]
``````

I’m wondering if I can somehow avoid those seams or maybe there is a good way to fix them after(smooth step after mutation). I have not noticed this behaviour when the terrain is attached. So maybe the cloning process causes issues? For that purpose I use deepClone on the terrain to replicate the terrain for a new cloned individual.

I hope this description helps. If not let me know and I’ll try to provide some kind of test case. Any help is appreciated!

make sure the borders are the same height, i think that the terrain requires this.

After a lot of smoothing attempts and trying to fix the seams on my own I actually found the error somewhere else in my code.
While I’m trying to clone individuals I used this code.
[java]