예제 #1
0
파일: simplex.py 프로젝트: tazjel/bravo
def bench2():
    times = []
    for i in range(25):
        before = time()
        for i in range(10000):
            simplex2(i, i)
        after = time()
        t = (after - before) / 10000
        times.append(1 / t)
    return "simplex2", times
예제 #2
0
파일: simplex.py 프로젝트: Mortal/bravo
def bench2():
    times = []
    for i in range(25):
        before = time()
        for i in range(10000):
            simplex2(i, i)
        after = time()
        t = (after - before) / 10000
        times.append(1/t)
    return "simplex2", times
예제 #3
0
    def populate(self, chunk, seed):
        """
        Make smooth waves of stone.
        """

        dees = seed ^ sys.maxint

        # And into one end he plugged the whole of reality as extrapolated
        # from a piece of fairy cake, and into the other end he plugged his
        # wife: so that when he turned it on she saw in one instant the whole
        # infinity of creation and herself in relation to it.

        factor = 1 / 64

        for x, z in product(xrange(16), repeat=2):
            magx = (chunk.x * 16 + x) * factor
            magz = (chunk.z * 16 + z) * factor

            set_seed(seed)
            should_cave = octaves2(magx, magz, 2)

            if should_cave > 0.2:
                set_seed(dees)
                depth = (simplex2(magx, magz) + 1) * 40
                height = depth // 10

                column = chunk.get_column(x, z)
                column[depth : depth + height].fill([blocks["air"].slot])
예제 #4
0
    def populate(self, chunk, seed):
        """
        Make smooth waves of stone.
        """

        dees = seed ^ sys.maxint

        # And into one end he plugged the whole of reality as extrapolated
        # from a piece of fairy cake, and into the other end he plugged his
        # wife: so that when he turned it on she saw in one instant the whole
        # infinity of creation and herself in relation to it.

        factor = 1 / 64

        for x, z in product(xrange(16), repeat=2):
            magx = (chunk.x * 16 + x) * factor
            magz = (chunk.z * 16 + z) * factor

            set_seed(seed)
            should_cave = octaves2(magx, magz, 2)

            if should_cave > 0.2:
                set_seed(dees)
                depth = (simplex2(magx, magz) + 1) * 40
                height = depth // 10

                column = chunk.get_column(x, z)
                column[depth:depth + height].fill([blocks["air"].slot])
예제 #5
0
count = 0
total = WIDTH * HEIGHT

print "Seed: %d" % options.seed
print "Coords: %f, %f" % (x, y)
print "Window: %fx%f" % (w, h)
print "Octaves: %d" % options.octaves
print "Offsets: %f, %f" % (xoffset, yoffset)

for i, j in product(xrange(WIDTH), xrange(HEIGHT)):
    count += 1
    if count >= counts[0]:
        print "Status: %d/%d (%.2f%%)" % (count, total, count * 100 / total)
        counts.append(counts.pop(0) * 10)

    # Get our scaled coords
    xcoord = x + w * i / WIDTH
    ycoord = y + h * j / HEIGHT

    # Get noise and scale from [-1, 1] to [0, 255]
    if xoffset or yoffset:
        noise = offset2(xcoord, ycoord, xoffset, yoffset, options.octaves)
    if options.octaves > 1:
        noise = octaves2(xcoord, ycoord, options.octaves)
    else:
        noise = simplex2(xcoord, ycoord)

    pbo[i, j] = int((noise + 1) * 127.5)

image.save("noise.png")
예제 #6
0
def time_simplex2(i):
    simplex2(i, i)
예제 #7
0
count = 0
total = WIDTH * HEIGHT

print "Seed: %d" % options.seed
print "Coords: %f, %f" % (x, y)
print "Window: %fx%f" % (w, h)
print "Octaves: %d" % options.octaves
print "Offsets: %f, %f" % (xoffset, yoffset)

for i, j in product(xrange(WIDTH), xrange(HEIGHT)):
    count += 1
    if count >= counts[0]:
        print "Status: %d/%d (%.2f%%)" % (count, total, count * 100 / total)
        counts.append(counts.pop(0) * 10)

    # Get our scaled coords
    xcoord = x + w * i / WIDTH
    ycoord = y + h * j / HEIGHT

    # Get noise and scale from [-1, 1] to [0, 255]
    if xoffset or yoffset:
        noise = offset2(xcoord, ycoord, xoffset, yoffset, options.octaves)
    if options.octaves > 1:
        noise = octaves2(xcoord, ycoord, options.octaves)
    else:
        noise = simplex2(xcoord, ycoord)

    pbo[i, j] = int((noise + 1) * 127.5)

image.save("noise.png")
예제 #8
0
def time_simplex2(i):
    simplex2(i, i)