From bcfde6fa4979f9391138826db35d4ffe70f02b90 Mon Sep 17 00:00:00 2001 From: Charles Peyrat Date: Thu, 21 Jan 2021 03:27:31 +0100 Subject: [PATCH] Move code around so loops placement isn't stopped by walls --- squirrelbattle/mapgeneration/broguelike.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/squirrelbattle/mapgeneration/broguelike.py b/squirrelbattle/mapgeneration/broguelike.py index 012a577..17fd3b8 100644 --- a/squirrelbattle/mapgeneration/broguelike.py +++ b/squirrelbattle/mapgeneration/broguelike.py @@ -489,7 +489,6 @@ class Generator: tries += 1 # post-processing - self.place_walls(level) # because when a room is placed, it leads to exactly one previously # placed room, the level has a tree like structure with the starting @@ -500,9 +499,13 @@ class Generator: while tries < self.params["loop_tries"] and \ loops < self.params["loop_max"]: tries += 1 + print(tries) y, x = randint(0, height - 1), randint(0, width - 1) loops += self.add_loop(level, y, x) + # surround the floor with walls + self.place_walls(level) + # place an exit ladder y, x = randint(0, height - 1), randint(0, width - 1) while level[y][x] != Tile.FLOOR or \