138 days ago · Tech · hide · Fediverse post

Hello, loves! I need a little something to do. Here’s something that could be done. Better code, not as easy to understand as it might be. There is absolutely no reason to work on this, except that I want to. There is this odd code in DungeonLayout: class DungeonLayout: # how does this relate to Flooder? def find_path(self, source, target, room_list): def can_use(cell, _parent): return self.is_available(cell) or self.get_room(cell) in room_list reached = self.path_map(source, can_use, 1.0) path = [] start = target while start is not None: path.append(start) start = reached.get(start) return path def path_map(self, source, can_use, randomness=0.0): reached: dict[Cell, Cell|None] = {source: None} for c, _ in (Flooder(layout=self, origin=source) .select(can_use) .randomness(randomness) .flood()): for neighbor in self.neighbors(c): if neighbor not in reached and can_use(neighbor, c): reached[neighbor] = c return reached OK, what is in the “path map” that the method returns? We are trying…

Commenting on Bubbles has been removed. Why? If you want to talk about this post, write to the author, use the comments on their blog if it has them, or reply with a "RE:" post on your own blog. Suggestions? feedback@bubbles.town