# How do games like Minecraft generate entire worlds from a seed number?

I want to generate a completely unique world with biomes (like what Minecraft and similar games do). I don't understand how they generate these entire worlds from a single "seed" number. Can someone provide a basic overview of the technique?

• 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. Oct 21, 2011 at 17:07

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. Jun 6, 2012 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.) Jun 6, 2012 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. " Jun 6, 2012 at 17:03