[url=http://notch.tumblr.com/]Source[/url]
[quote][b]Terrain generation, Part 1[/b]
I’ve been promising to write a technical post on Minecraft for a while, but never really got around to doing so. I’m on a tiny airplane now, though, with nowhere to run, so here we go!
One of the most complex parts of Minecraft is the terrain generation. When I changed the game over from being just single zones of a map to an infinite map, the terrain generation got a whole lot more complicated, as terrain needs to get generated on the fly as the player explores, and it has to be the same no matter what direction the player approaches it from.
[b]1) How infinite is it?[/b]
First of all, let me clarify some things about the “infinite” maps: They’re not infinite, but there’s no hard limit either. It’ll just get buggier and buggier the further out you are. Terrain is generated, saved and loaded, and (kind of) rendered in chunks of 16*16*128 blocks. These chunks have an offset value that is a 32 bit integer roughly in the range negative two billion to positive two billion. If you go outside that range (about 25% of the distance from where you are now to the sun), loading and saving chunks will start overwriting old chunks. At a 16/th of that distance, things that use integers for block positions, such as using items and pathfinding, will start overflowing and acting weird.
Those are the two “hard” limits.
Most other things, like the terrain generation seeds and entity locations use 64 bit doubles for locations, and they do much subtler things. For example, at extreme distances, the player may move slower than near the center of the world, due to rounding errors (the position has a huge mantissa, the movement delta has a tiny, so it gets cut off faster). The terrain generator can also start generating weird structures, such as huge blocks of solid material, but I haven’t seen this lately nor examined exactly what behavior causes it to happen. One major problem at long distances is that the physics starts bugging out, so the player can randomly fall into ground blocks or get stuck while walking along a wall.
Many of these problems can be solved by changing the math into a local model centered around the player so the numbers all have vaguely the same magnitude. For rendering, Minecraft already uses local coordinates within the block and offset the block position relative to the player to give the impression of the player moving. This is mostly due to OpengGL using 32 bit floats for positions, but also because the rounding errors are extremely visible when displayed on a screen.
We’re probably not going to fix these bugs until it becomes common for players to experience them while playing legitimately. My gut feeling is that nobody ever has so far, and nobody will. Walking that far will take a very long time. Besides, the bugs add mystery and charisma to the Far Lands.
[b]2) Isn’t that terrain shape pretty awesome?[/b]
In the very earliest version of Minecraft, I used a 2D Perlin noise heightmap to set the shape of the world. Or, rather, I used quite a few of them. One for overall elevation, one for terrain roughness, and one for local detail. For each column of blocks, the height was (elevation + (roughness*detail))*64+64. Both elevation and roughness were smooth, large scale noises, and detail was a more intricate one. This method had the great advantage of being very fast as there’s just 16*16*(noiseNum) samples per chunk to generate, but the disadvantage of being rather dull. Specifically, there’s no way for this method 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. To make sure the bottom layer is solid and the top isn’t, I just add the height (offset by the water level) to the sampled result.
Unfortunately, I immediately ran into both performance issues and playability issues. Performance issues because of the huge amount of sampling needed to be done, and playability issues because there were no flat areas or smooth hills. The solution to both problems turned out to be just sampling at a lower resolution (scaled 8x along the horizontals, 4x along the vertical) and doing a linear interpolation. Suddenly, the game had flat areas, smooth hills, and also most single floating blocks were gone.
The exact formula I use is a bit involved (and secret!), but it evolved slowly over time as I worked on the game. It still uses the 2D elevation and noisyness maps, though.
[b]STILL TO COME, ON TERRAIN GENERATION:[/b]
- Biomes!
- Caves and Large Features
- Trees, Lakes, and Small Features
- The nether![/quote]
[quote][b]They’re not infinite,[/b] but there’s no hard limit either.[/quote]
[quote]The terrain generator can also start generating weird structures, [b]such as huge blocks of solid material[/b], but I haven’t seen this lately nor examined exactly what behavior causes it to happen.[/quote]
Dun dun dunnnn. :monocle:
I challenge someone to get to the point where the savegame starts fucking up.
Notch said they weren't infinite a long time ago.
[editline]9th March 2011[/editline]
[QUOTE=Netsc;28517336]I challenge someone to get to the point where the savegame starts fucking up.[/QUOTE]
Old, but same principles.
[media]http://www.youtube.com/watch?v=M1JtvFNr4vg[/media]
[QUOTE=Netsc;28517336]I challenge someone to get to the point where the savegame starts fucking up.[/QUOTE]
Or where they start finding towers or diamond ore.
As you can see, Notch has implemented floating islands. It's just really big. :buddy:
Now how do seeds fit into this?
Since we're on the topic of glitchy worlds has anyone ever found natural cobblestone on a newly generated map?
[QUOTE=Aces;28517460]Since we're on the topic of glitchy worlds has anyone ever found natural cobblestone on a newly generated map?[/QUOTE]
1 block in the sky.
I thought it was odd because i don't see how cobblestone would even be on a list of blocks to be generated.
Dungeons have normal cobble don't they?
[media]http://www.youtube.com/watch?v=wCjOd7STjac[/media]
This happened to me after converting.
[QUOTE=Aces;28517460]Since we're on the topic of glitchy worlds has anyone ever found natural cobblestone on a newly generated map?[/QUOTE]
I've found natural dirt on a newly generated map.
I haven't seen a single space in the bedrock in a long time, has anyone seen a split in the bedrock?
Funny, I had chunk glitches yesterday, I think it was due to walking a few miles from the original spawn location, when I quit and came back I had lost all my items and a huge random chunk of hill was in the spot my road was at.
[QUOTE=Esteam;28517701]I've found natural dirt on a newly generated map.
I haven't seen a single space in the bedrock in a long time, has anyone seen a split in the bedrock?[/QUOTE]
Yes i've seen lots.
[QUOTE=Esteam;28517701]I've found natural dirt on a newly generated map.
I haven't seen a single space in the bedrock in a long time, has anyone seen a split in the bedrock?[/QUOTE]
Nearly everytime I reach bedrock.
[QUOTE=Esteam;28517701]I've found natural dirt on a newly generated map.[/QUOTE]
Um, there is natural dirt everywhere, it's prolly the 2nd most used block in generating worlds. :v:
[QUOTE=Aces;28518028]Um, there is natural dirt everywhere, it's prolly the 2nd most used block in generating worlds. :v:[/QUOTE]
lol wow
[QUOTE=Esteam;28518104]lol wow[/QUOTE]
wat
[QUOTE=Aces;28518248]wat[/QUOTE]
you missed the joke entirely
[QUOTE=Esteam;28518269]you missed the joke entirely[/QUOTE]
Oh
[QUOTE=Esteam;28517701]I've found natural dirt on a newly generated map.
I haven't seen a single space in the bedrock in a long time, has anyone seen a split in the bedrock?[/QUOTE]
I once found a lake in the bedrock on my server, but that is about it. The sad part is that that map was soo screwed up I had to delete it.
[QUOTE=Esteam;28518269]you missed the joke entirely[/QUOTE]
It wasn't a very good one to be honest.
[QUOTE=sbradford26;28517654][media]http://www.youtube.com/watch?v=wCjOd7STjac[/media]
This happened to me after converting.[/QUOTE]
All that happened to my converted map was a bunch of areas where my guy would randomly become stuck in place.
[QUOTE=MacTrekkie;28519233]It wasn't a very good one to be honest.[/QUOTE]
oh no im sad now
[QUOTE=Esteam;28520210]oh no im sad now[/QUOTE]
Did it hurt your self [I]Esteam[/I]? :downsrim:
[QUOTE=sbradford26;28517654][media]http://www.youtube.com/watch?v=wCjOd7STjac[/media]
This happened to me after converting.[/QUOTE]
Holy shit.
[QUOTE=Im-Bored;28520301]Did it hurt your self [I]Esteam[/I]? :downsrim:[/QUOTE]
thats not even how you spell e oh
ha i get it !!!
[QUOTE=sbradford26;28517654][media]http://www.youtube.com/watch?v=wCjOd7STjac[/media]
This happened to me after converting.[/QUOTE]
Could you upload that map?
[QUOTE=Esteam;28517701]I've found natural dirt on a newly generated map.
I haven't seen a single space in the bedrock in a long time, has anyone seen a split in the bedrock?[/QUOTE]
I've had a lake/line of water which started from the surface then went all the way down to bedrock then past it.
I'm guessing a set of chunks all got corrupted in that world.
Do the shit in those videos do the same thing in SMP maps?
That'd be sweet.
[QUOTE=sbradford26;28517654][media]http://www.youtube.com/watch?v=wCjOd7STjac[/media]
This happened to me after converting.[/QUOTE]
Whats with the hacked in tools. I'm not saying you hacked in all those ores or anything, but why did you have to hack in diamond tools when you have all that ore. And why didn you hide it when the video started? And why did you hack in 64 stacks of tools?
Sorry, you need to Log In to post a reply to this thread.