1 hour ago · Tech · hide · 0 comments

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…

No comments yet. Log in to reply on the Fediverse. Comments will appear here.