fixes amount of rooms
This commit is contained in:
+3
-3
@@ -70,18 +70,18 @@ pixels=[[0]*width for _ in range(height)] # aanspreken als pixels[y][x] (rows co
|
|||||||
# map cluster centers to pixels:
|
# 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]
|
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):
|
for i, c in enumerate(cluster_pixels):
|
||||||
pixels[c[1]][c[0]] = i
|
pixels[c[1]][c[0]] = i+1
|
||||||
|
|
||||||
epochs = 0
|
epochs = 0
|
||||||
while epochs < 20:
|
while epochs < 20:
|
||||||
for i, c in enumerate(cluster_pixels):
|
for i, c in enumerate(cluster_pixels):
|
||||||
for y, row in enumerate(pixels):
|
for y, row in enumerate(pixels):
|
||||||
for x, cell in enumerate(row):
|
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.
|
nx = x-random.randrange(-1,2) # randrange heeft non-inclusive upperbound. leuk.
|
||||||
ny = y-random.randrange(-1,2)
|
ny = y-random.randrange(-1,2)
|
||||||
if nx >= 0 and ny >= 0 and nx < width and ny < height and pixels[ny][nx] == 0:
|
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
|
epochs += 1
|
||||||
printPixels(pixels)
|
printPixels(pixels)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user