Switching up the tiles used during generation to the correct ones

This commit is contained in:
Charles Peyrat 2020-12-11 01:09:49 +01:00
parent d40a61554e
commit 021731b740
1 changed files with 5 additions and 4 deletions

View File

@ -58,7 +58,7 @@ class Generator:
def run(self):
width, height = self.params["width"], self.params["height"]
walkers = [Walker(width//2, height//2)]
grid = [[Tile.WALL for _ in range(width)] for _ in range(height)]
grid = [[Tile.EMPTY for _ in range(width)] for _ in range(height)]
count = 0
while count < self.params["fill"] * width*height:
# because we can't add or remove walkers while looping over the pop
@ -68,9 +68,9 @@ class Generator:
failsafe = choice(walkers)
for walker in walkers:
if grid[walker.y][walker.x] == Tile.WALL:
if grid[walker.y][walker.x] == Tile.EMPTY:
count += 1
grid[walker.y][walker.x] = Tile.EMPTY
grid[walker.y][walker.x] = Tile.FLOOR
if random() < self.params["turn_chance"]:
walker.random_turn()
walker.move_in_bounds(width, height)
@ -91,8 +91,9 @@ class Generator:
next_walker_pop.append(walker.split())
walkers = next_walker_pop
start_x, start_y = randint(0, width), randint(0, height)
while grid[start_y][start_x] != Tile.EMPTY:
while grid[start_y][start_x] != Tile.FLOOR:
start_x, start_y = randint(0, width), randint(0, height)
return Map(width, height, grid, start_x, start_y)