fixes amount of rooms

This commit is contained in:
2023-11-18 17:11:39 +01:00
parent 561df931a2
commit 9d9d6087c4
+3 -3
View File
@@ -70,18 +70,18 @@ pixels=[[0]*width for _ in range(height)] # aanspreken als pixels[y][x] (rows co
# map cluster centers to pixels:
cluster_pixels = [(int(c[0]/domains[0][1]*width), int(c[1]/domains[1][1]*height))for c in centroids]
for i, c in enumerate(cluster_pixels):
pixels[c[1]][c[0]] = i
pixels[c[1]][c[0]] = i+1
epochs = 0
while epochs < 20:
for i, c in enumerate(cluster_pixels):
for y, row in enumerate(pixels):
for x, cell in enumerate(row):
if cell == i:
if cell == i+1:
nx = x-random.randrange(-1,2) # randrange heeft non-inclusive upperbound. leuk.
ny = y-random.randrange(-1,2)
if nx >= 0 and ny >= 0 and nx < width and ny < height and pixels[ny][nx] == 0:
pixels[ny][nx] = i
pixels[ny][nx] = i+1
epochs += 1
printPixels(pixels)