# SolvedDifficult programming/logic question

#### kaz

##### Coder
Full Member
Nobleman
So I'm trying to develop a randomly generated terrain using vertices and then making a surface out of them connecting triangles(2) to make a solid 4 cornered piece of land.
My logic is confusing me and then derailing my train of thought.
I'm looking for a less complicated way of approaching this.

Here's my style

size = 30
name[500]

For(x=0;x<size;x++){
For(z=0;z<size;x++){
y=y-(rand(-1,1))
}
}

The result is not what I want nor what I can work with to create bigger lands if the y value for the x(1) goes down and the x(2) goes upwards.

I thought of another way but this would require an array inside an array so I could grab each any every point/vertex then comparing it to the one that will be next to it to keep the ground within a -1 through 1 point of the last; leaving the code a mess.
I drew a image to make it clear in my head. result;

coding this would be a pain in the ass and be hard to work with if I wanted to modify.

Anyone have a better way of doing this, I have all the coding down and drawings already set up.
I just want to know how I would randomize the Y axis but still create a realistic texture, similar to minecraft style of generation.

#### kaz

##### Coder
Full Member
Nobleman
solved it,

perlin noise:
2d perlin noise

The white pixels are height and black are lower.

3d perlin noise requires pasting perlin noises on others, this will allow overhangs and caves underneath the terrain.

Attention! Before you post:

99% of questions are answered in the Beginner's Guide, do it before asking a question.

No Hack Requests. Post in the correct section.  Search the forum first. Read the rules.

How to make a good post:

• Fill out the form correctly
• Tell us the game name & coding language