Closed ajh123 closed 3 years ago
@obiwac i've uploaded it now
Just tried out your PR, looking good!
Couple things I'd like to point out, though.
On GitHub, it is preferable not to include binary files, such as all the __pycache__
and *.pyc
files you included. Only the source. Now usually, you'd use a valid .gitignore
file in the root of your repository, which you seem to have, so honestly I don't know why they're still included. Git being wierd I guess. But you can use the git rm "filename"
command to manually remove files from git before comitting.
From your code (world.py
line 61):
random_num = random.randint(1, 2)
extra_noise = noise.pnoise3(chunk_x/16+random_num/random_num, chunk_y/16+random_num, chunk_z/16+random_num/random_num)
is_cave = noise.pnoise3(chunk_x/16+random_num+extra_noise, chunk_y/16+extra_noise+random_num, chunk_z/16+extra_noise)
I can see you've attempted to introduce a bit more variation by offsetting the noise arguments by a small, random amount. You can actually use the pnoise3
function's 4th argument, the "octave", to add however many octaves of noise on top of the main noise function as you want. For example, if I wanted to add 4 octaves:
scale = 16.0
is_cave = noise.pnoise((x * chunk.CHUNK_WIDTH + chunk_x) / scale, (chunk_y) / scale, (z * chunk.CHUNK_LENGTH + chunk_z) / scale, **octaves = 4**)
This gives a much more natural-looking result:
I'm not going to merge this PR because this repository is strictly meant for the source code of each episode in my tutorial series, nothing more, but I think what you've added is really cool! When I'm going to cover terrain generation (probably in quite a few episodes), caves will be done in a very similar manner.
Have a wonderful day!
Im Sam_H on the discord