1
저는 최근 게임을 위해 절차 적으로 생성 된 지형을 만들기 위해 노력해 왔습니다. 나는 Perlin 소음이 이것을 위해 유용하다는 것을 알았고, 그래서 나는 그것을 한방에 줬다. 지금까지 지형은 아름답게 생성됩니다. 그러나 프로그램을 여러 번 실행할 때마다 지형은 똑같습니다. 생성 된 Perlin 노이즈를 무작위로 추출 할 수있는 방법이 있습니까?Perlin 노이즈를위한 파이썬 랜덤 시드
코드 :
from opensimplex import OpenSimplex
import random
from time import time
height = 40
width = height
scale = height/10
value = [[0 for x in range(width)] for y in range(height)]
gen = OpenSimplex()
def noise(nx, ny):
# Rescale from -1.0:+1.0 to 0.0:1.0
return gen.noise2d(nx, ny)/2.0 + 0.5
def printBiome(y, x):
if value[y][x] <= 2:
print('O', end = " ")
elif value[y][x] >= 8:
print('M', end = " ")
else:
print('L', end = " ")
for y in range(height):
for x in range(width):
nx = x/width - 0.5
ny = y/height - 0.5
value[y][x] = 10 * noise(1 * scale * nx, 1 * scale * ny) + 0.5 * noise(2 * scale * nx, 2 * scale* ny) + 0.25 * noise(4 * scale * nx, 4 * scale * ny)
for y in range(height):
for x in range(width):
printBiome(y, x)
print()