From c8b07b3bf59175e2285fe57cb487b254cfd55f9a Mon Sep 17 00:00:00 2001 From: Charles Peyrat Date: Fri, 11 Dec 2020 17:17:11 +0100 Subject: [PATCH] Only empty tiles should be changed to walls, obviously... --- squirrelbattle/mapgeneration/randomwalk.py | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/squirrelbattle/mapgeneration/randomwalk.py b/squirrelbattle/mapgeneration/randomwalk.py index 3ef2b2d..b913d1c 100644 --- a/squirrelbattle/mapgeneration/randomwalk.py +++ b/squirrelbattle/mapgeneration/randomwalk.py @@ -107,10 +107,11 @@ class Generator: # post-processing: add walls for x in range(width): for y in range(height): - c = sum([1 if grid[j][i] == Tile.FLOOR else 0 for j, i in result.large_neighbourhood(y, x)]) - if c == 4 and self.params["no_lone_walls"]: - result.tiles[y][x] = Tile.FLOOR - elif c > 0: - result.tiles[y][x] = Tile.WALL + if grid[y][x] == Tile.EMPTY: + c = sum([1 if grid[j][i] == Tile.FLOOR else 0 for j, i in result.large_neighbourhood(y, x)]) + if c == 4 and self.params["no_lone_walls"]: + result.tiles[y][x] = Tile.FLOOR + elif c > 0: + result.tiles[y][x] = Tile.WALL return result