# How does Minecraft world generation happen?

How does Minecraft create completely unique worlds and biomes, from a seed?

-

## migrated from gaming.stackexchange.comOct 21 '11 at 18:15

This question came from our site for passionate videogamers on all platforms.

Notch actually wrote a blog post about terrain generation, which is now completely obsolete since the new code's got biomes and FRACTALS and other such wizardry. There never was a part 2, either. –  lunboks Oct 21 '11 at 17:07
Are there more informations about the actual world generator revealed until now? –  danijar Aug 8 '12 at 21:25

1. How do you generate random X from a seed? a seed value is the initial state of a random number generator. In most programming languages, you can set this seed. For example, C uses `srand()`. If you don't specify a specific seed to start with, usually a timestamp value is used as the seed. That way, each time you run, the random numbers are different.

``````// C example
srand(1);
for(i=0; i<3; i++)
printf("%d\n", rand());
srand(1);
for(i=0; i<3; i++)
printf("%d\n", rand());

1270216262
1085377743
1481765933
1270216262
1085377743
1481765933
``````

As you can see, whenever you seed with a certain value (I used 1 as a seed), the resulting random numbers are the same.

2. How do you create a minecraft-life world based on random numbers? Notch has a post about this. Also, you can check out other people's tutorials on "minecraft-like worlds". I enjoyed this one, for example: Minecraft-like rendering in OpenGL 4. The basic idea is to use Perlin noise (or simplex noise). Here is a good question about noise functions: Understanding Perlin Noise

-
Actually, you wont be able to use Perlin Noise I'm afraid minecraft has over-hanging cliffs, caves and so on, and PN cannot into that. –  jco Jun 6 '12 at 9:02
Perlin noise is just a noise system which you can use as part of a larger terrain generation method. eg. You can use 3D perlin noise with an altitude-dependent threshold value to generate cliffs, caves, etc. (Edit - in fact, I see from the link in the answer that is exactly what Notch was doing at one point.) –  Kylotan Jun 6 '12 at 15:17
+1 Kylotan. Here's the quote from Notch's blog: "Specifically, there’s no way for [2D Perlin heightmap] to generate any overhangs. So I switched the system over into a similar system based off 3D Perlin noise. Instead of sampling the “ground height”, I treated the noise value as the “density”, where anything lower than 0 would be air, and anything higher than or equal to 0 would be ground. " –  Jimmy Jun 6 '12 at 17:03