Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Terrain generation #47

Closed
BertrandBordage opened this issue Apr 8, 2013 · 18 comments
Closed

Terrain generation #47

BertrandBordage opened this issue Apr 8, 2013 · 18 comments

Comments

@BertrandBordage
Copy link
Collaborator

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?

@ronmurphy
Copy link
Collaborator

i THINK it is how some one had planned to generate terrain ... but i dont think that it ever went any where.

@Jimx-
Copy link
Collaborator

Jimx- commented Apr 8, 2013

Terrain.py is a terrain generation algorithm. It uses 2D Perlin Noise to generate a random height map(Minecraft uses 3D Perlin Noise).

@Jimx-
Copy link
Collaborator

Jimx- commented Apr 13, 2013

I just tested the new terrain generation algorithm in terrain.py and now it seems to be able to generate some minecraft style terrains:)
a9

@ghost
Copy link

ghost commented Apr 13, 2013

@Jimx- 👍

@ronmurphy
Copy link
Collaborator

@Jimx- 👍 That is Awesome!

@ronmurphy
Copy link
Collaborator

@Jimx- How can I make this the default terrain generator?

@BertrandBordage
Copy link
Collaborator Author

Consider this as a question from everyone :)

@ronmurphy
Copy link
Collaborator

Glad it is not just me :) I have been trying to figure out how to make this the default for an hour now...

@Nebual
Copy link
Collaborator

Nebual commented Apr 14, 2013

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.

@ronmurphy
Copy link
Collaborator

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?

@Nebual
Copy link
Collaborator

Nebual commented Apr 14, 2013

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

@Nebual Nebual closed this as completed Apr 14, 2013
@BertrandBordage
Copy link
Collaborator Author

???? I don't think we still have a proper terrain generator…

@Nebual
Copy link
Collaborator

Nebual commented Apr 14, 2013

Oops sorry, misclicked! Did not mean to close this.

@Jimx-
Copy link
Collaborator

Jimx- commented Apr 14, 2013

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.

@ronmurphy
Copy link
Collaborator

but it would be nice to see how it works...

@BertrandBordage
Copy link
Collaborator Author

Yes, it could be cool if you explain us how to get it working!

@ronmurphy
Copy link
Collaborator

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 :)

@Jimx-
Copy link
Collaborator

Jimx- commented Apr 15, 2013

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()...

@Nebual Nebual closed this as completed May 5, 2013
arruda pushed a commit to arruda/Minecraft-Python that referenced this issue Nov 9, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants