Closed BertrandBordage closed 11 years ago
i THINK it is how some one had planned to generate terrain ... but i dont think that it ever went any where.
Terrain.py is a terrain generation algorithm. It uses 2D Perlin Noise to generate a random height map(Minecraft uses 3D Perlin Noise).
I just tested the new terrain generation algorithm in terrain.py and now it seems to be able to generate some minecraft style terrains:)
@Jimx- :+1:
@Jimx- :thumbsup: That is Awesome!
@Jimx- How can I make this the default terrain generator?
Consider this as a question from everyone :)
Glad it is not just me :) I have been trying to figure out how to make this the default for an hour now...
I think Jimx has far more locally than he's committed, theres nothing that interfaces with the rest of the engine in .generate_chunk yet. Also, attempting to run just the PerlinNoise.fBm function once per block took a good 6 seconds for a single Region. His current design runs that at least 5 times per block, so this implementation is currently not possible for realtime generation.
Is anyone else having terrain issues? i did git pull today... and terrain land (flat) generates past the wall... and up in the sky. is this just me, or am i so dense that i am missing obvious code changes?
Yes, I added that in #60, to show that the wold is now infinite. If you want to try inventing a generator, the flat grass is from world._show_sector
???? I don't think we still have a proper terrain generator…
Oops sorry, misclicked! Did not mean to close this.
So far it takes a long time to generate the terrain...So I don't think it's a good idea to make it the default terrain generator.
but it would be nice to see how it works...
Yes, it could be cool if you explain us how to get it working!
maybe if we reduce the height map from what looks to be 40 blocks to 20, or 15, the terrain would generate faster. I am sure that all of us would much rather have this generator than the current one... not that anything is bad with the current one, just... this one has the potential to be so much better :)
Sorry for not replying earlier...I have to go to school... Notch wrote a post about the terrain generation in Minecraft here: http://notch.tumblr.com/post/3746989361/terrain-generation-part-1
To generate the terrain, this generator first uses PerlinNoise to generate some smooth random values, and adds them up to get a density. If a block has a density lower than 0, it will be air. And if a blocks has a density >= 0, it will be ground. I currently use 6 Perlin Noise Generators: one for base terrain, two for river/ocean, two for mountain/hill and one for cave. The formula is:
density = -y + (((32.0 + base_terrain * 32.0) * self._clamp(river + 0.25) * self._clamp(ocean + 0.25)) + mountains * 1024.0 + hills * 128.0) * flatten
-y
makes sure that the bottom layer is solid but the top isn't. Because density will be smaller and smaller as y increases.
(((32.0 + base_terrain * 32.0) * self._clamp(river + 0.25) * self._clamp(ocean + 0.25))
generates the base terrain, if ocean and river are both small values, it will generate river or ocean.
mountains * 1024.0 + hills * 128.0
generates mountains and hills, it will generate some blocks at higher positions if mountains and hills are positive.
And here are the lines with which I generated the terrain:
tg = TerrainGenerator(seed)
c = tg.generate_chunk(0, 0, 0) # generate the chunk at (0, 0, 0)
for x in range(0, CHUNK_X_SIZE):
for z in range(0, CHUNK_Z_SIZE):
for y in range(0, CHUNK_Y_SIZE): # set blocks
self.init_block((c.world_block_xpos(x), y, c.world_block_zpos(z)), c.get_block(world_block_xpos(x), y, world_block_pos(z)))
This is how the terrain generator works. And I just found that math.floor() is much faster than my fast_floor()...
There is a "terrain.py" file in the repository. Why?
Besides, we need to discuss on how will terrain generation work. For the moment, the whole map is generated when starting the game. But how will we do to have this kind of two dimensional stream that generates coherent terrain?