0

このノイズ モジュールを現在取り組んでいるプロジェクトに適応させようとしていますが、期待していた結果が得られません: https://pypi.python.org/pypi/noise/

さまざまな height-mapの代わりに、各行はまったく同じ値を持つ傾向があります。250x250 を作成すると、同じ値が 250 回生成され、終了するまで新しい値が 250 回生成されます。

現在使っている機能はこちら。私はこの機能をかなりよく理解していますが、より「興味深い」結果を得る方法がわかりません。ご協力ありがとうございました。

class SimplexNoise(BaseNoise):

    def noise2(self, x, y):
        """2D Perlin simplex noise. 

        Return a floating point value from -1 to 1 for the given x, y coordinate. 
        The same value is always returned for a given x, y pair unless the
        permutation table changes (see randomize above). 
        """
        # Skew input space to determine which simplex (triangle) we are in
        s = (x + y) * _F2
        i = floor(x + s)
        j = floor(y + s)
        t = (i + j) * _G2
        x0 = x - (i - t) # "Unskewed" distances from cell origin
        y0 = y - (j - t)

        if x0 > y0:
            i1 = 1; j1 = 0 # Lower triangle, XY order: (0,0)->(1,0)->(1,1)
        else:
            i1 = 0; j1 = 1 # Upper triangle, YX order: (0,0)->(0,1)->(1,1)

        x1 = x0 - i1 + _G2 # Offsets for middle corner in (x,y) unskewed coords
        y1 = y0 - j1 + _G2
        x2 = x0 + _G2 * 2.0 - 1.0 # Offsets for last corner in (x,y) unskewed coords
        y2 = y0 + _G2 * 2.0 - 1.0

        # Determine hashed gradient indices of the three simplex corners
        perm = BaseNoise.permutation      
        ii = int(i) % BaseNoise.period
        jj = int(j) % BaseNoise.period
        gi0 = perm[ii + perm[jj]] % 12
        gi1 = perm[ii + i1 + perm[jj + j1]] % 12
        gi2 = perm[ii + 1 + perm[jj + 1]] % 12

        # Calculate the contribution from the three corners
        tt = 0.5 - x0**2 - y0**2
        if tt > 0:
            g = _GRAD3[gi0]
            noise = tt**4 * (g[0] * x0 + g[1] * y0)
        else:
            noise = 0.0

        tt = 0.5 - x1**2 - y1**2
        if tt > 0:
            g = _GRAD3[gi1]
            noise += tt**4 * (g[0] * x1 + g[1] * y1)

        tt = 0.5 - x2**2 - y2**2
        if tt > 0:
            g = _GRAD3[gi2]
            noise += tt**4 * (g[0] * x2 + g[1] * y2)

        return noise * 70.0 # scale noise to [-1, 1]

win = pygcurse.PygcurseWindow(85, 70, 'Generate')

octaves = 2
ysize = 150
xsize = 150
freq = 32.0 * octaves

for y in range(ysize):
    for x in range(xsize):
        tile = SimplexNoise.noise2(x / freq, y / freq, octaves)
        win.write(str(tile) + "\n")
4

0 に答える 0