Created
January 11, 2015 16:11
-
-
Save fogleman/959a30ea7abe011632e2 to your computer and use it in GitHub Desktop.
Generate Mountain in Craft
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from builder import * | |
from world import * | |
from time import sleep | |
def mountain(x, y, z, w, radius, height, noise): | |
client = get_client() | |
set_block = client.set_block | |
set_blocks = client.set_blocks | |
for dx in range(-radius * 2, radius * 2 + 1): | |
for dz in range(-radius * 2, radius * 2 + 1): | |
px, pz = float(dx) / radius, float(dz) / radius | |
p = 1 / (1 + px * px + pz * pz) | |
p = (p - 0.5) * 2 | |
p = max(0.0, p) | |
p = p ** 2 | |
q = 1 / (1 + px * px + pz * pz) | |
m = 3 | |
n = dll_simplex2(px * m, pz * m, 8) * noise - noise / 2.0 | |
ch = height * (p + n * q) | |
for dy in range(40): | |
by = y + ch - dy | |
if by < 1: | |
continue | |
set_block(x + dx, by, z + dz, w) | |
print dx | |
sleep(0.01) | |
raw_input() | |
if __name__ == '__main__': | |
mountain(0, 0, 0, 6, 256/4, 128/4, 0.5) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment