Ejemplo n.º 1
0
    def populate(self, chunk, seed):
        """
        Make smooth waves of stone.
        """

        sede = seed ^ 0xcafebabe
        xzfactor = 1 / 128
        yfactor = 1 / 64

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

            column = chunk.get_column(x, z)

            for y in range(128):
                if not column[y]:
                    continue
                magy = y * yfactor

                set_seed(seed)
                should_cave = abs(octaves3(magx, magz, magy, 3))
                set_seed(sede)
                should_cave *= abs(octaves3(magx, magz, magy, 3))

                if should_cave < 0.002:
                    column[y] = blocks["air"].slot
Ejemplo n.º 2
0
    def populate(self, chunk, seed):
        """
        Make smooth waves of stone.
        """

        sede = seed ^ 0xcafebabe
        xzfactor = 1 / 128
        yfactor = 1 / 64

        for x, z in XZ:
            magx = (chunk.x * 16 + x) * xzfactor
            magz = (chunk.z * 16 + z) * xzfactor

            for y in range(CHUNK_HEIGHT):
                if not chunk.get_block((x, y, z)):
                    continue

                magy = y * yfactor

                set_seed(seed)
                should_cave = abs(octaves3(magx, magz, magy, 3))
                set_seed(sede)
                should_cave *= abs(octaves3(magx, magz, magy, 3))

                if should_cave < 0.002:
                    chunk.set_block((x, y, z), blocks["air"].slot)
Ejemplo n.º 3
0
    def populate(self, chunk, seed):
        """
        Make smooth waves of stone.
        """

        sede = seed ^ 0xCAFEBABE
        xzfactor = 1 / 128
        yfactor = 1 / 64

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

            for y in range(128):
                if not chunk.get_block((x, y, z)):
                    continue

                magy = y * yfactor

                set_seed(seed)
                should_cave = abs(octaves3(magx, magz, magy, 3))
                set_seed(sede)
                should_cave *= abs(octaves3(magx, magz, magy, 3))

                if should_cave < 0.002:
                    chunk.set_block((x, y, z), blocks["air"].slot)
Ejemplo n.º 4
0
    def populate(self, chunk, seed):
        """
        Make smooth waves of stone.
        """

        sede = seed ^ 0xcafebabe
        xzfactor = 1 / 128
        yfactor = 1 / 64

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

            column = chunk.get_column(x, z)

            for y in range(128):
                if not column[y]:
                    continue
                magy = y * yfactor

                set_seed(seed)
                should_cave = abs(octaves3(magx, magz, magy, 3))
                set_seed(sede)
                should_cave *= abs(octaves3(magx, magz, magy, 3))

                if should_cave < 0.002:
                    column[y] = blocks["air"].slot
Ejemplo n.º 5
0
    def populate(self, chunk, seed):
        """
        Make smooth waves of stone.
        """

        sede = seed ^ 0xcafebabe
        xzfactor = 1 / 128
        yfactor = 1 / 64

        for x, z in XZ:
            magx = (chunk.x * 16 + x) * xzfactor
            magz = (chunk.z * 16 + z) * xzfactor

            for y in range(CHUNK_HEIGHT):
                if not chunk.get_block((x, y, z)):
                    continue

                magy = y * yfactor

                set_seed(seed)
                should_cave = abs(octaves3(magx, magz, magy, 3))
                set_seed(sede)
                should_cave *= abs(octaves3(magx, magz, magy, 3))

                if should_cave < 0.002:
                    chunk.set_block((x, y, z), blocks["air"].slot)
Ejemplo n.º 6
0
    def populate(self, chunk, seed):
        """
        Make smooth islands of stone.
        """

        set_seed(seed)

        factor = 1 / 256

        for x, z, y in iterchunk():
            magx = (chunk.x * 16 + x) * factor
            magz = (chunk.z * 16 + z) * factor

            sample = octaves3(magx, magz, y * factor, 6)

            if sample > 0.5:
                chunk.set_block((x, y, z), blocks["stone"].slot)
Ejemplo n.º 7
0
    def populate(self, chunk, seed):
        """
        Make smooth islands of stone.
        """

        set_seed(seed)

        factor = 1 / 256

        for x, z, y in iterchunk():
            magx = (chunk.x * 16 + x) * factor
            magz = (chunk.z * 16 + z) * factor

            sample = octaves3(magx, magz, y * factor, 6)

            if sample > 0.5:
                chunk.set_block((x, y, z), blocks["stone"].slot)
Ejemplo n.º 8
0
    def populate(self, chunk, seed):
        """
        Make smooth islands of stone.
        """

        set_seed(seed)

        factor = 1 / 256

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

            sample = octaves3(magx, magz, y * factor, 6)

            if sample > 0.1:
                chunk.set_block((x, y, z), blocks["stone"].slot)
            elif sample > 0:
                chunk.set_block((x, y, z), blocks["dirt"].slot)
Ejemplo n.º 9
0
    def populate(self, chunk, seed):
        """
        Make smooth islands of stone.
        """

        set_seed(seed)

        factor = 1 / 256

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

            samples = array([octaves3(magx, magz, y * factor, 6) for y in xrange(column.size)])

            column = where(samples > 0, blocks["dirt"].slot, column)
            column = where(samples > 0.1, blocks["stone"].slot, column)

            chunk.set_column(x, z, column)
Ejemplo n.º 10
0
    def populate(self, chunk, seed):
        """
        Make smooth islands of stone.
        """

        set_seed(seed)

        factor = 1 / 256

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

            samples = array([octaves3(magx, magz, y * factor, 6)
                    for y in xrange(column.size)])

            column = where(samples > 0, blocks["dirt"].slot, column)
            column = where(samples > 0.1, blocks["stone"].slot, column)

            chunk.set_column(x, z, column)
Ejemplo n.º 11
0
    def populate(self, chunk, seed):
        reseed(seed)

        xzfactor = 1 / 16
        yfactor = 1 / 32

        for x, z in product(xrange(16), repeat=2):
            for y in range(chunk.heightmap[x, z] + 1):
                magx = (chunk.x * 16 + x) * xzfactor
                magz = (chunk.z * 16 + z) * xzfactor
                magy = y * yfactor

                sample = octaves3(magx, magz, magy, 3)

                if sample > 0.9999:
                    # Figure out what to place here.
                    old = chunk.get_block((x, y, z))
                    if old == blocks["sand"].slot:
                        # Sand becomes clay.
                        chunk.set_block((x, y, z), blocks["clay"].slot)
                    elif old == blocks["dirt"].slot:
                        # Dirt becomes gravel.
                        chunk.set_block((x, y, z), blocks["gravel"].slot)
                    elif old == blocks["stone"].slot:
                        # Stone becomes one of the ores.
                        if y < 12:
                            chunk.set_block((x, y, z),
                                blocks["diamond-ore"].slot)
                        elif y < 24:
                            chunk.set_block((x, y, z),
                                blocks["gold-ore"].slot)
                        elif y < 36:
                            chunk.set_block((x, y, z),
                                blocks["redstone-ore"].slot)
                        elif y < 48:
                            chunk.set_block((x, y, z),
                                blocks["iron-ore"].slot)
                        else:
                            chunk.set_block((x, y, z),
                                blocks["coal-ore"].slot)
Ejemplo n.º 12
0
    def populate(self, chunk, seed):
        set_seed(seed)

        xzfactor = 1 / 16
        yfactor = 1 / 32

        for x, z in XZ:
            for y in range(chunk.height_at(x, z) + 1):
                magx = (chunk.x * 16 + x) * xzfactor
                magz = (chunk.z * 16 + z) * xzfactor
                magy = y * yfactor

                sample = octaves3(magx, magz, magy, 3)

                if sample > 0.9999:
                    # Figure out what to place here.
                    old = chunk.get_block((x, y, z))
                    new = None
                    if old == blocks["sand"].slot:
                        # Sand becomes clay.
                        new = blocks["clay"].slot
                    elif old == blocks["dirt"].slot:
                        # Dirt becomes gravel.
                        new = blocks["gravel"].slot
                    elif old == blocks["stone"].slot:
                        # Stone becomes one of the ores.
                        if y < 12:
                            new = blocks["diamond-ore"].slot
                        elif y < 24:
                            new = blocks["gold-ore"].slot
                        elif y < 36:
                            new = blocks["redstone-ore"].slot
                        elif y < 48:
                            new = blocks["iron-ore"].slot
                        else:
                            new = blocks["coal-ore"].slot

                    if new:
                        chunk.set_block((x, y, z), new)
Ejemplo n.º 13
0
    def populate(self, chunk, seed):
        set_seed(seed)

        xzfactor = 1 / 16
        yfactor = 1 / 32

        for x, z in product(xrange(16), repeat=2):
            for y in range(chunk.heightmap[x, z] + 1):
                magx = (chunk.x * 16 + x) * xzfactor
                magz = (chunk.z * 16 + z) * xzfactor
                magy = y * yfactor

                sample = octaves3(magx, magz, magy, 3)

                if sample > 0.9999:
                    # Figure out what to place here.
                    old = chunk.blocks[x, z, y]
                    new = None
                    if old == blocks["sand"].slot:
                        # Sand becomes clay.
                        new = blocks["clay"].slot
                    elif old == blocks["dirt"].slot:
                        # Dirt becomes gravel.
                        new = blocks["gravel"].slot
                    elif old == blocks["stone"].slot:
                        # Stone becomes one of the ores.
                        if y < 12:
                            new = blocks["diamond-ore"].slot
                        elif y < 24:
                            new = blocks["gold-ore"].slot
                        elif y < 36:
                            new = blocks["redstone-ore"].slot
                        elif y < 48:
                            new = blocks["iron-ore"].slot
                        else:
                            new = blocks["coal-ore"].slot

                    if new:
                        chunk.blocks[x, z, y] = new
Ejemplo n.º 14
0
 def test_identity(self):
     for i in range(512):
         self.assertEqual(simplex(i, i), octaves2(i, i, 1))
     for i in range(512):
         self.assertEqual(simplex(i, i, i), octaves3(i, i, i, 1))
Ejemplo n.º 15
0
def time_octaves3(i):
    octaves3(i, i, i, 5)
Ejemplo n.º 16
0
 def test_identity(self):
     for i in range(512):
         self.assertEqual(simplex(i, i), octaves2(i, i, 1))
     for i in range(512):
         self.assertEqual(simplex(i, i, i), octaves3(i, i, i, 1))
Ejemplo n.º 17
0
def time_octaves3(i):
    octaves3(i, i, i, 5)