def run(self): to_traverse = self.graph_node_list for node in to_traverse: node.prepare_traversal() while to_traverse: # Not particularly performant, needs review to_traverse = sorted( to_traverse, key=lambda node: node.neighbours_to_traverse_count()) node = to_traverse.pop(0) while node.get_neighbours_to_traverse(): # Revert this commented code once we support trunks in monolane # generator if node.is_minor_road: road = Street() else: road = Trunk() if node.neighbours_count() > 1: self.city.add_intersection_at(node.location) road.add_control_point(node.location) self._build_road(road, None, node) if road.node_count() > 1: self.city.add_road(road)
def _create_inner_streets(self, city, size): # Vertical for x in range(1, size - 1): road = Street() for y in range(size): road.add_control_point(self.intersections[x][y]) city.add_road(road) # Horizontal for y in range(1, size - 1): road = Street() for x in range(size): road.add_control_point(self.intersections[x][y]) city.add_road(road) # Diagonals road = Street() for i in range(size): road.add_control_point(self.intersections[i][i]) city.add_road(road) road = Street() for i in range(size): road.add_control_point(self.intersections[i][size - i - 1]) city.add_road(road)