diff --git a/dungeonbattle/mapgeneration/randomwalk.py b/dungeonbattle/mapgeneration/randomwalk.py index 60baaba..3aaad70 100644 --- a/dungeonbattle/mapgeneration/randomwalk.py +++ b/dungeonbattle/mapgeneration/randomwalk.py @@ -66,6 +66,7 @@ class Generator: # next iteration of the main loop next_walker_pop = [] + failsafe = choice(walkers) for walker in walkers: if grid[walker.y][walker.x] == Tile.WALL: count += 1 @@ -76,6 +77,10 @@ class Generator: if random() > self.params["death_chance"]: next_walker_pop.append(walker) + # we make sure to never kill all walkers + if next_walker_pop == []: + next_walker_pop.append(failsafe) + # we use a second loop for spliting so we're not bothered by cases # like a walker not spliting because we hit the population cap even # though the next one would have died and freed a place