Le 0Head qui a mal pull
This commit is contained in:
@@ -57,25 +57,6 @@ class Bin:
|
|||||||
self.grid[rect_y][rect_x] = False
|
self.grid[rect_y][rect_x] = False
|
||||||
|
|
||||||
|
|
||||||
def pack_rectangles(rectangles, grid):
|
|
||||||
rectangles = sorted(
|
|
||||||
rectangles, key=lambda r: r.width * r.height, reverse=True)
|
|
||||||
bins = [Bin(grid)]
|
|
||||||
|
|
||||||
for rectangle in rectangles:
|
|
||||||
for bin in bins:
|
|
||||||
if bin.place_rectangle(rectangle):
|
|
||||||
break
|
|
||||||
else:
|
|
||||||
new_bin = Bin(grid)
|
|
||||||
if new_bin.place_rectangle(rectangle):
|
|
||||||
bins.append(new_bin)
|
|
||||||
else:
|
|
||||||
return False
|
|
||||||
|
|
||||||
return True
|
|
||||||
|
|
||||||
|
|
||||||
def generate_rectangle(min_width: int = 10, max_width: int = 25):
|
def generate_rectangle(min_width: int = 10, max_width: int = 25):
|
||||||
width = randint(min_width, max_width)
|
width = randint(min_width, max_width)
|
||||||
height = randint(min_width, max_width)
|
height = randint(min_width, max_width)
|
||||||
@@ -117,5 +98,3 @@ def generate_building(image: Union[str, Image], heightmap: Union[str, Image], ou
|
|||||||
return rectangles
|
return rectangles
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
|
||||||
generate_building()
|
|
||||||
|
|||||||
Reference in New Issue
Block a user