From 436f38c068e51612d7e50f8ab7490e26dbf66dd5 Mon Sep 17 00:00:00 2001 From: Eclairsombre Date: Sun, 21 Apr 2024 21:18:47 +0200 Subject: [PATCH 01/18] Add House.py --- House.py | 89 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ main.py | 8 ++--- 2 files changed, 93 insertions(+), 4 deletions(-) create mode 100644 House.py diff --git a/House.py b/House.py new file mode 100644 index 0000000..dfa39b2 --- /dev/null +++ b/House.py @@ -0,0 +1,89 @@ +from gdpc import Editor, Block, geometry +import networks.curve as curve +import numpy as np + + +class House : + def __init__(self, editor,startX, startY, startZ, endX, endY, endZ): + self.editor = editor + self.startX = startX + self.startY = startY + self.startZ = startZ + self.endX = endX + self.endY = endY + self.endZ = endZ + + + def placeGround(self): + for x in range(self.startX, self.endX): + for z in range(self.startZ, self.endZ): + self.editor.placeBlock((x, self.startY, z), Block("stone")) + + def placeWall(self): + for x in range(self.startX, self.endX+1): + for y in range(self.startY, self.endY): + self.editor.placeBlock((x, y, self.startZ), Block("oak_planks")) + self.editor.placeBlock((x, y, self.endZ), Block("oak_planks")) + for z in range(self.startZ, self.endZ+1): + for y in range(self.startY, self.endY): + self.editor.placeBlock((self.startX, y, z), Block("oak_planks")) + self.editor.placeBlock((self.endX, y, z), Block("oak_planks")) + + def placeRoof(self): + for x in range(self.startX, self.endX+1): + for z in range(self.startZ, self.endZ+1): + self.editor.placeBlock((x, self.endY, z), Block("stone")) + + def placeDoor(self,direction="north"): + if direction == "north": + x = (self.startX + self.endX) // 2 + self.editor.placeBlock((x, self.startY, self.startZ), Block("air")) + self.editor.placeBlock((x, self.startY+1, self.startZ), Block("air")) + self.editor.placeBlock((x, self.startY+2, self.startZ), Block("air")) + elif direction == "south": + x = (self.startX + self.endX) // 2 + self.editor.placeBlock((x, self.startY, self.endZ), Block("air")) + self.editor.placeBlock((x, self.startY+1, self.endZ), Block("air")) + self.editor.placeBlock((x, self.startY+2, self.endZ), Block("air")) + elif direction == "west": + z = (self.startZ + self.endZ) // 2 + self.editor.placeBlock((self.startX, self.startY, z), Block("air")) + self.editor.placeBlock((self.startX, self.startY+1, z), Block("air")) + self.editor.placeBlock((self.startX, self.startY+2, z), Block("air")) + elif direction == "east": + z = (self.startZ + self.endZ) // 2 + self.editor.placeBlock((self.endX, self.startY, z), Block("air")) + self.editor.placeBlock((self.endX, self.startY+1, z), Block("air")) + self.editor.placeBlock((self.endX, self.startY+2, z), Block("air")) + + def placeHouse(self): + self.clearInside() + self.placeGround() + self.placeWall() + self.placeRoof() + self.placeDoor() + + def clearInside(self): + for x in range(self.startX+1, self.endX): + for y in range(self.startY+1, self.endY): + for z in range(self.startZ+1, self.endZ): + self.editor.placeBlock((x, y, z), Block("air")) + + def clear(self): + for x in range(self.startX, self.endX+1): + for y in range(self.startY, self.endY+1): + for z in range(self.startZ, self.endZ+1): + self.editor.placeBlock((x, y, z), Block("air")) + +if __name__ == "__main__": + editor = Editor(buffering=True) + house = House(editor, 17, -58, 8, 30, -50, 20) + house.placeHouse() + #house.clear() + editor.flushBuffer() + + + + + + diff --git a/main.py b/main.py index 1f43c45..742c224 100644 --- a/main.py +++ b/main.py @@ -8,7 +8,7 @@ editor = Editor(buffering=True) # block = editor.getBlock((0,48,0)) # # Place a block -# editor.placeBlock((394, 132, 741), Block("stone")) +editor.placeBlock((-5, -58, 0), Block("stone")) # # Build a cube # geometry.placeCuboid(editor, (458, 92, 488), (468, 99, 471), Block("oak_planks")) @@ -17,6 +17,6 @@ curve = curve.Curve([(396, 132, 740), (435, 138, 730), (443, 161, 758), (417, 73, 729)]) curve.compute_curve() -for point in curve.computed_points: - print(point) - editor.placeBlock(point, Block("stone")) +#for point in curve.computed_points: +# print(point) +# editor.placeBlock(point, Block("stone")) From 8d93372edeed4728b24f0323c8be2c085f3acf99 Mon Sep 17 00:00:00 2001 From: Eclairsombre Date: Thu, 25 Apr 2024 21:37:27 +0200 Subject: [PATCH 02/18] Add houseSkeleton --- House.py | 171 +++++++++++++------------ HouseBackup.py | 335 +++++++++++++++++++++++++++++++++++++++++++++++++ list_block.py | 70 +++++++++++ 3 files changed, 498 insertions(+), 78 deletions(-) create mode 100644 HouseBackup.py create mode 100644 list_block.py diff --git a/House.py b/House.py index dfa39b2..40b71af 100644 --- a/House.py +++ b/House.py @@ -1,89 +1,104 @@ + from gdpc import Editor, Block, geometry -import networks.curve as curve +from list_block import * import numpy as np - -class House : - def __init__(self, editor,startX, startY, startZ, endX, endY, endZ): +class House: + def __init__(self, editor, coordinates_min, coordinates_max): self.editor = editor - self.startX = startX - self.startY = startY - self.startZ = startZ - self.endX = endX - self.endY = endY - self.endZ = endZ - - - def placeGround(self): - for x in range(self.startX, self.endX): - for z in range(self.startZ, self.endZ): - self.editor.placeBlock((x, self.startY, z), Block("stone")) - - def placeWall(self): - for x in range(self.startX, self.endX+1): - for y in range(self.startY, self.endY): - self.editor.placeBlock((x, y, self.startZ), Block("oak_planks")) - self.editor.placeBlock((x, y, self.endZ), Block("oak_planks")) - for z in range(self.startZ, self.endZ+1): - for y in range(self.startY, self.endY): - self.editor.placeBlock((self.startX, y, z), Block("oak_planks")) - self.editor.placeBlock((self.endX, y, z), Block("oak_planks")) - - def placeRoof(self): - for x in range(self.startX, self.endX+1): - for z in range(self.startZ, self.endZ+1): - self.editor.placeBlock((x, self.endY, z), Block("stone")) - - def placeDoor(self,direction="north"): - if direction == "north": - x = (self.startX + self.endX) // 2 - self.editor.placeBlock((x, self.startY, self.startZ), Block("air")) - self.editor.placeBlock((x, self.startY+1, self.startZ), Block("air")) - self.editor.placeBlock((x, self.startY+2, self.startZ), Block("air")) - elif direction == "south": - x = (self.startX + self.endX) // 2 - self.editor.placeBlock((x, self.startY, self.endZ), Block("air")) - self.editor.placeBlock((x, self.startY+1, self.endZ), Block("air")) - self.editor.placeBlock((x, self.startY+2, self.endZ), Block("air")) - elif direction == "west": - z = (self.startZ + self.endZ) // 2 - self.editor.placeBlock((self.startX, self.startY, z), Block("air")) - self.editor.placeBlock((self.startX, self.startY+1, z), Block("air")) - self.editor.placeBlock((self.startX, self.startY+2, z), Block("air")) - elif direction == "east": - z = (self.startZ + self.endZ) // 2 - self.editor.placeBlock((self.endX, self.startY, z), Block("air")) - self.editor.placeBlock((self.endX, self.startY+1, z), Block("air")) - self.editor.placeBlock((self.endX, self.startY+2, z), Block("air")) - - def placeHouse(self): - self.clearInside() - self.placeGround() - self.placeWall() - self.placeRoof() - self.placeDoor() - - def clearInside(self): - for x in range(self.startX+1, self.endX): - for y in range(self.startY+1, self.endY): - for z in range(self.startZ+1, self.endZ): - self.editor.placeBlock((x, y, z), Block("air")) - - def clear(self): - for x in range(self.startX, self.endX+1): - for y in range(self.startY, self.endY+1): - for z in range(self.startZ, self.endZ+1): - self.editor.placeBlock((x, y, z), Block("air")) + self.coordinates_min = coordinates_min + self.coordinates_max = coordinates_max + self.skeleton = [] + + def createHouseSkeleton(self): + self.delete() + x_min, y_min, z_min = self.coordinates_min + x_max, y_max, z_max = self.coordinates_max + + for i in range (x_min, x_max): + for y in range(z_min, z_max): + if i == x_min or i == x_max - 1 or y == z_min or y == z_max - 1: + self.editor.placeBlock((i, y_min, y), Block("oak_planks")) + + perimeter_width = x_max - x_min + perimeter_depth = z_max - z_min + + + x = np.random.randint(x_min+1 , x_max-1) + z = np.random.randint(z_min+1 , z_max-1 ) + + width = perimeter_width // 2 + depth = perimeter_depth // 2 + + if x + width-1 > x_max-1: + x = x_max - width-1 + if z + depth-1 > z_max-1: + z = z_max - depth-1 + + for i in range(0, width-1): + for j in range(0, depth-1): + self.editor.placeBlock((x + i, y_min, z + j), Block("stone")) + + self.skeleton.append((x, z, width, depth)) + + block = ["redstone_block", "gold_block", "diamond_block"] + + for _ in range(3): + print("Rectangle n°", _+1, "en cours de création") + while True: + new_width = np.random.randint(width//3, width-2) + new_depth = np.random.randint(depth//3, depth-2) + new_x = np.random.choice([x - new_width, x + width - 1]) + if new_x >= x +width or new_x <= x: + new_z = np.random.choice([z - new_depth + np.random.randint(2,depth), z + depth - 1 -+ np.random.randint(2,depth)]) + else: + new_z = np.random.choice([z - new_depth, z + depth - 1]) + if new_z >= z + depth or new_z <= z: + new_x = np.random.choice([x - new_width + np.random.randint(2,width), x + width - 1 - np.random.randint(2,width)]) + + if new_x + new_width-1 > x_max-1: + new_x = x_max - new_width-1 + if new_z + new_depth-1 > z_max-1: + new_z = z_max - new_depth-1 + + if new_x >= x_min+1 and new_x + new_width <= x_max-1 and new_z >= z_min+1 and new_z + new_depth <= z_max-1 and not self.checkOverlap(new_x, new_z, new_width, new_depth): + for i in range(0, new_width): + for j in range(0, new_depth): + self.editor.placeBlock((new_x + i, y_min, new_z + j), Block(block[_])) + + self.skeleton.append((new_x, new_z, new_width, new_depth)) + break + + def checkOverlap(self, x, z, width, depth): + for skeleton in self.skeleton: + x_skeleton, z_skeleton, width_skeleton, depth_skeleton = skeleton + if x < x_skeleton + width_skeleton and x + width > x_skeleton and z < z_skeleton + depth_skeleton and z + depth > z_skeleton: + return True + + return False + + def delete(self): + for x in range(self.coordinates_min[0], self.coordinates_max[0]): + for y in range(self.coordinates_min[1], self.coordinates_max[1]): + for z in range(self.coordinates_min[2], self.coordinates_max[2]): + self.editor.placeBlock((x, y, z), Block("air")) + + if __name__ == "__main__": editor = Editor(buffering=True) - house = House(editor, 17, -58, 8, 30, -50, 20) - house.placeHouse() - #house.clear() + buildArea = editor.getBuildArea() + coordinates_min = [min(buildArea.begin[i], buildArea.last[i]) for i in range(3)] + coordinates_max = [max(buildArea.begin[i], buildArea.last[i]) for i in range(3)] + + house = House(editor, coordinates_min, coordinates_max) + house.createHouseSkeleton() + + + + # delete(editor, coordinates_min, coordinates_max) editor.flushBuffer() - - - + \ No newline at end of file diff --git a/HouseBackup.py b/HouseBackup.py new file mode 100644 index 0000000..9cf94b0 --- /dev/null +++ b/HouseBackup.py @@ -0,0 +1,335 @@ +from gdpc import Editor, Block, geometry +from list_block import * +import numpy as np +import math + + +class House : + def __init__(self, editor,startX, startY, startZ, endX, endY, endZ,style,houseDirection="north"): + self.editor = editor + self.startX = startX + self.startY = startY + self.startZ = startZ + self.endX = endX + self.endY = endY + self.endZ = endZ + self.houseDirection = houseDirection + self.hasGarder = True + self.gardenSide = "right" + self.hasGarage = True + + self.wall = style['mur'] + self.ground = style['sol'] + self.grass = style['grass'] + self.path = style['chemin'] + self.fence = style['fence'] + self.glass = style['glass'] + self.door = style['door'] + self.roof = style['toit'] + + def placeGround(self,CoStart, CoEnd,block): + for x in range(CoStart[0], CoEnd[0]): + for z in range(CoStart[2], CoEnd[2]): + self.editor.placeBlock((x, CoStart[1], z), Block(block) ) + + def placeRoof(self,CoStart,CoEnd): + for x in range(CoStart[0], CoEnd[0]): + for z in range(CoStart[2], CoEnd[2]): + self.editor.placeBlock((x, CoEnd[1]-1, z), Block(self.roof)) + + + def placeWall(self,CoStart,CoEnd): + if CoStart[0] == CoEnd[0]: + for y in range(CoStart[1]+1, CoEnd[1]-1): + for z in range(CoStart[2], CoEnd[2]): + self.editor.placeBlock((CoStart[0], y, z), Block(self.wall)) + CoStart = (CoStart[0],CoStart[1],CoStart[2]+1) + CoEnd = (CoEnd[0],CoEnd[1],CoEnd[2]-1) + elif CoStart[2] == CoEnd[2]: + for y in range(CoStart[1]+1, CoEnd[1]-1): + for x in range(CoStart[0], CoEnd[0]): + self.editor.placeBlock((x, y, CoStart[2]), Block(self.wall)) + CoStart = (CoStart[0]+1,CoStart[1],CoStart[2]) + CoEnd = (CoEnd[0]-1,CoEnd[1],CoEnd[2]) + + self.placeWindow(CoStart,CoEnd) + + + + + def placeDoor(self, direction="north", x=0, z=0, y=0): + door_directions = { + "south": {"facing": "north", "half": "lower"}, + "north": {"facing": "south", "half": "lower"}, + "east": {"facing": "west", "half": "lower"}, + "west": {"facing": "east", "half": "lower"} + } + + door_properties = door_directions.get(direction) + + if door_properties: + self.editor.placeBlock((x, y + 1, z), Block(self.door, door_properties)) + self.editor.placeBlock((x, y + 2, z), Block(self.door, {"facing": door_properties["facing"], "half": "upper"})) + self.doorDirection = direction + + def placeWindow(self, CoStart, CoEnd): + x = abs(CoEnd[0] - CoStart[0]) + z = abs(CoEnd[2] - CoStart[2]) + type = Block(self.glass) + + def placeBlock(axis, is_x_axis): + print(axis, is_x_axis) + if axis % 2 == 0: + if axis == 4: + if is_x_axis: + self.editor.placeBlock((CoStart[0] + 1, CoStart[1] + 2, CoStart[2]), type) + self.editor.placeBlock((CoStart[0] + 2, CoStart[1] + 2, CoStart[2]), type) + else: + self.editor.placeBlock((CoStart[0], CoStart[1] + 2, CoStart[2] + 1), type) + self.editor.placeBlock((CoStart[0], CoStart[1] + 2, CoStart[2] + 2), type) + else: + for i in range(axis // 2): + if i % 2 == 0: + if is_x_axis: + self.editor.placeBlock((CoStart[0] + i * 2 + 1, CoStart[1] + 2, CoStart[2]), type) + self.editor.placeBlock((CoStart[0] + i * 2 + 2, CoStart[1] + 2, CoStart[2]), type) + else: + self.editor.placeBlock((CoStart[0], CoStart[1] + 2, CoStart[2] + 1 + i * 2), type) + self.editor.placeBlock((CoStart[0], CoStart[1] + 2, CoStart[2] + i * 2 + 2), type) + else: + if axis <= 5: + for i in range(axis): + if is_x_axis: + self.editor.placeBlock((CoStart[0] + i, CoStart[1] + 2, CoStart[2]), type) + else: + self.editor.placeBlock((CoStart[0], CoStart[1] + 2, CoStart[2] + i), type) + else: + for i in range(axis // 3): + if 3 * (i + 1) + i > abs(CoEnd[2] - CoStart[2]): + break + else: + if is_x_axis: + self.editor.placeBlock((CoStart[0], CoStart[1] + 2, CoStart[2] + i * 4), type) + self.editor.placeBlock((CoStart[0], CoStart[1] + 2, CoStart[2] + i * 4 + 1), type) + self.editor.placeBlock((CoStart[0], CoStart[1] + 2, CoStart[2] + i * 4 + 2), type) + else: + self.editor.placeBlock((CoStart[0], CoStart[1] + 2, CoStart[2] + i * 4), type) + self.editor.placeBlock((CoStart[0], CoStart[1] + 2, CoStart[2] + i * 4 + 1), type) + self.editor.placeBlock((CoStart[0], CoStart[1] + 2, CoStart[2] + i * 4 + 2), type) + + if CoStart[0] == CoEnd[0]: + placeBlock(z, False) + + if CoStart[2] == CoEnd[2]: + placeBlock(x, True) + + + + def clearInside(self): + for x in range(self.startX+1, self.endX): + for y in range(self.startY+1, self.endY): + for z in range(self.startZ+1, self.endZ): + self.editor.placeBlock((x, y, z), air) + + + def deleteWall(self,CoStart,CoEnd): + if CoStart[0] == CoEnd[0]: + for y in range(CoStart[1]+1, CoEnd[1]-1): + for z in range(CoStart[2], CoEnd[2]): + self.editor.placeBlock((CoStart[0], y, z), air) + elif CoStart[2] == CoEnd[2]: + for y in range(CoStart[1]+1, CoEnd[1]-1): + for x in range(CoStart[0], CoEnd[0]): + self.editor.placeBlock((x, y, CoStart[2]), air) + + + def placeGarage(self,CoStart,CoEnd): + self.deleteWall(CoStart,CoEnd) + + + + + + + def placeHouse(self): + self.clear() + self.clearInside() + self.placeGround((self.startX, self.startY, self.startZ), (self.endX, self.endY, self.endZ),self.ground) + + if self.hasGarder: + if self.houseDirection == "north" : + if self.gardenSide == "left": + self.placeGround((self.startX+ (self.endX - self.startX)//2, self.startY, self.startZ), (self.endX, self.endY, self.startZ + (self.endZ - self.startZ)//2), self.grass) + self.placeRoof((self.startX, self.startY, self.startZ), (self.endX - (self.endX - self.startX)//2, self.endY, self.endZ)) + self.placeRoof((self.startX + (self.endX - self.startX)//2, self.startY, self.startZ + (self.endZ - self.startZ)//2), (self.endX, self.endY, self.endZ)) + self.placeWall((self.startX, self.startY, self.startZ), (self.startX +(self.endX - self.startX)//2 , self.endY, self.startZ)) + self.placeWall((self.startX, self.startY, self.startZ), (self.startX, self.endY, self.endZ )) + self.placeWall((self.startX, self.startY, self.endZ-1), (self.endX , self.endY, self.endZ-1)) + self.placeWall((self.endX-1, self.startY, self.startZ+ (self.endZ - self.startZ)//2), (self.endX-1, self.endY, self.endZ)) + self.placeWall((self.startX + (self.endX - self.startX)//2 , self.startY, self.startZ+ (self.endZ - self.startZ)//2), (self.endX , self.endY, self.startZ+ (self.endZ - self.startZ)//2)) + self.placeWall((self.startX + (self.endX - self.startX)//2 -1, self.startY, self.startZ), (self.startX + (self.endX - self.startX)//2 -1, self.endY, self.startZ+ (self.endZ - self.startZ)//2 )) + self.placeDoor("north", self.endX - (self.endX -self.startX) // 4 -1 , (self.startZ + self.endZ) //2,self.startY) + if self.hasGarage: + self.placeGarage((self.startX+1, self.startY, self.startZ), (self.startX +(self.endX - self.startX)//2 -1 , self.endY, self.startZ)) + + else: + self.placeGround((self.startX, self.startY, self.startZ), (self.startX + (self.endX-self.startX)//2, self.endY, self.startZ + (self.endZ - self.startZ)//2), self.grass) + self.placeRoof((self.endX- (self.endX - self.startX)//2, self.startY, self.startZ), (self.endX , self.endY, self.endZ)) + self.placeRoof((self.startX , self.startY, self.startZ + (self.endZ - self.startZ)//2), (self.endX - (self.endX - self.startX)//2, self.endY, self.endZ)) + self.placeWall((self.startX, self.startY, self.startZ+ (self.endZ - self.startZ)//2), (self.endX - (self.endX - self.startX)//2, self.endY, self.startZ+ (self.endZ - self.startZ)//2)) + self.placeWall((self.startX, self.startY, self.startZ+ (self.endZ - self.startZ)//2), (self.startX, self.endY, self.endZ )) + self.placeWall((self.startX, self.startY, self.endZ-1), (self.endX , self.endY, self.endZ-1)) + self.placeWall((self.endX-1, self.startY, self.startZ), (self.endX-1, self.endY, self.endZ)) + self.placeWall((self.startX+ (self.endX - self.startX)//2, self.startY, self.startZ), (self.endX, self.endY, self.startZ)) + self.placeWall((self.startX+ (self.endX - self.startX)//2, self.startY, self.startZ), (self.startX+ (self.endX - self.startX)//2, self.endY, self.startZ+ (self.endZ - self.startZ)//2)) + self.placeDoor("north", self.startX + (self.endX -self.startX) // 4 , (self.startZ + self.endZ) //2,self.startY) + if self.hasGarage: + self.placeGarage((self.startX+ (self.endX - self.startX)//2 +1, self.startY, self.startZ), (self.endX-1, self.endY, self.startZ)) + + elif self.houseDirection == "south": + if self.gardenSide == "left": + self.placeGround((self.startX , self.startY, self.startZ + (self.endZ - self.startZ)//2), (self.startX+ (self.endX - self.startX)//2, self.endY, self.endZ), self.grass) + self.placeRoof((self.startX, self.startY, self.startZ), (self.endX, self.endY, self.startZ + (self.endZ - self.startZ)//2)) + self.placeRoof((self.startX + (self.endX - self.startX)//2, self.startY, self.startZ), (self.endX, self.endY, self.endZ)) + self.placeWall((self.startX, self.startY, self.startZ), (self.endX , self.endY, self.startZ)) + self.placeWall((self.startX, self.startY, self.startZ), (self.startX , self.endY, self.startZ + (self.endZ - self.startZ)//2)) + self.placeWall((self.startX, self.startY, self.startZ + (self.endZ - self.startZ)//2 -1), (self.startX + (self.endX - self.startX)//2 , self.endY, self.startZ + (self.endZ - self.startZ)//2 -1)) + self.placeWall((self.startX + (self.endX - self.startX)//2, self.startY, self.endZ-1), (self.endX , self.endY, self.endZ-1)) + self.placeWall((self.startX + (self.endX - self.startX)//2, self.startY, self.startZ + (self.endZ - self.startZ)//2), (self.startX + (self.endX - self.startX)//2, self.endY, self.endZ)) + self.placeWall((self.endX-1, self.startY, self.startZ), (self.endX-1, self.endY, self.endZ)) + + self.placeDoor("south", self.startX + (self.endX -self.startX) // 4 , (self.startZ + self.endZ) //2 -1,self.startY) + if self.hasGarage: + self.placeGarage((self.startX+1, self.startY, self.startZ + (self.endZ - self.startZ)//2 +1), (self.startX +(self.endX - self.startX)//2 -1, self.endY, self.endZ -1)) + + else: + self.placeGround((self.startX + (self.endX - self.startX)//2, self.startY, self.startZ+ (self.endZ - self.startZ)//2), (self.endX, self.endY, self.endZ), self.grass) + self.placeRoof((self.startX, self.startY, self.startZ), (self.startX+(self.endX - self.startX)//2 , self.endY, self.endZ)) + self.placeRoof((self.startX + (self.endX - self.startX)//2, self.startY, self.startZ), (self.endX, self.endY, self.startZ+(self.endZ - self.startZ)//2)) + self.placeWall((self.startX, self.startY, self.startZ), (self.endX , self.endY, self.startZ)) + self.placeWall((self.startX, self.startY, self.startZ), (self.startX , self.endY, self.endZ)) + self.placeWall((self.startX, self.startY, self.endZ-1), (self.startX + (self.endX - self.startX)//2 , self.endY, self.endZ-1)) + self.placeWall((self.startX + (self.endX - self.startX)//2 -1, self.startY, self.startZ + (self.endZ - self.startZ)//2), (self.startX + (self.endX - self.startX)//2 -1, self.endY, self.endZ )) + self.placeWall((self.startX + (self.endX - self.startX)//2, self.startY, self.startZ + (self.endZ - self.startZ)//2 -1), (self.endX , self.endY, self.startZ + (self.endZ - self.startZ)//2 -1)) + self.placeWall((self.endX -1, self.startY, self.startZ ), (self.endX -1, self.endY, self.startZ+ (self.endZ - self.startZ)//2)) + + + self.placeDoor("south", self.endX - (self.endX -self.startX) // 4 -1 , (self.startZ + self.endZ) //2 -1,self.startY) + if self.hasGarage: + self.placeGarage((self.startX+ (self.endX - self.startX)//2 +1, self.startY, self.startZ + (self.endZ - self.startZ)//2 +1), (self.endX-1, self.endY, self.endZ -1)) + + elif self.houseDirection == "west": + if self.gardenSide == "left": + self.placeGround((self.startX, self.startY, self.startZ), (self.startX + (self.endX - self.startX)//2, self.endY, self.startZ+ (self.endZ - self.startZ)//2), self.grass) + self.placeRoof((self.startX + (self.endX - self.startX)//2, self.startY, self.startZ), (self.endX, self.endY, self.endZ)) + self.placeRoof((self.startX, self.startY, self.startZ+ (self.endZ - self.startZ)//2), (self.startX + (self.endX - self.startX)//2, self.endY, self.endZ)) + self.placeWall((self.startX+ (self.endX - self.startX)//2, self.startY, self.startZ), (self.endX, self.endY, self.startZ)) + self.placeWall((self.startX+ (self.endX - self.startX)//2, self.startY, self.startZ), (self.startX+ (self.endX - self.startX)//2, self.endY, self.startZ+ (self.endZ - self.startZ)//2)) + self.placeWall((self.endX-1, self.startY, self.startZ), (self.endX-1, self.endY, self.endZ)) + self.placeWall((self.startX, self.startY, self.startZ+ (self.endZ - self.startZ)//2), (self.startX+ (self.endX - self.startX)//2, self.endY, self.startZ+ (self.endZ - self.startZ)//2)) + self.placeWall((self.startX, self.startY, self.startZ+ (self.endZ - self.startZ)//2), (self.startX, self.endY, self.endZ)) + self.placeWall((self.startX, self.startY, self.endZ-1), (self.endX, self.endY, self.endZ-1)) + self.placeDoor("west", self.endX - (self.endX -self.startX) // 2 , self.startZ + (self.endZ - self.startZ)//4 ,self.startY) + if self.hasGarage: + self.placeGarage((self.startX, self.startY, self.startZ+ (self.endZ - self.startZ)//2 +1), (self.startX , self.endY, self.endZ -1)) + else: + self.placeGround((self.startX, self.startY, self.startZ+ (self.endZ - self.startZ)//2 ), (self.startX+ (self.endX-self.startX)//2, self.endY, self.endZ), self.grass) + self.placeRoof((self.startX + (self.endX - self.startX)//2, self.startY, self.startZ+ (self.endZ - self.startZ)//2), (self.endX, self.endY, self.endZ)) + self.placeRoof((self.startX, self.startY, self.startZ), (self.endX, self.endY, self.startZ+ (self.endZ - self.startZ)//2)) + self.placeWall((self.startX, self.startY, self.startZ+ (self.endZ - self.startZ)//2 -1), (self.startX+ (self.endX - self.startX)//2, self.endY, self.startZ+ (self.endZ - self.startZ)//2 -1)) + self.placeWall((self.startX, self.startY, self.startZ), (self.endX, self.endY, self.startZ)) + self.placeWall((self.startX, self.startY, self.startZ), (self.startX, self.endY, self.startZ+ (self.endZ - self.startZ)//2)) + self.placeWall((self.startX + (self.endX - self.startX)//2, self.startY, self.endZ-1), (self.endX, self.endY, self.endZ-1)) + self.placeWall((self.startX + (self.endX - self.startX)//2, self.startY, self.startZ+ (self.endZ - self.startZ)//2), (self.startX + (self.endX - self.startX)//2, self.endY, self.endZ)) + self.placeWall((self.endX-1, self.startY, self.startZ), (self.endX-1, self.endY, self.endZ)) + + self.placeDoor("west", self.startX + (self.endX -self.startX) // 2 , self.endZ - (self.endZ - self.startZ)//4 -1,self.startY) + if self.hasGarage: + self.placeGarage((self.startX, self.startY, self.startZ+1), (self.startX, self.endY, self.startZ+ (self.endZ - self.startZ)//2 -1)) + + elif self.houseDirection == "east": + if self.gardenSide == "left": + self.placeGround((self.startX + (self.endX - self.startX)//2, self.startY, self.startZ+ (self.endZ - self.startZ)//2), (self.endX , self.endY, self.endZ, self.grass), self.grass) + self.placeRoof((self.startX, self.startY, self.startZ), (self.startX + (self.endX - self.startX)//2, self.endY, self.endZ)) + self.placeRoof((self.startX + (self.endX - self.startX)//2, self.startY, self.startZ), (self.endX, self.endY, self.startZ+ (self.endZ - self.startZ)//2)) + self.placeWall((self.startX, self.startY, self.startZ), (self.endX , self.endY, self.startZ)) + self.placeWall((self.startX, self.startY, self.startZ), (self.startX, self.endY, self.endZ)) + self.placeWall((self.startX, self.startY, self.endZ-1), (self.startX + (self.endX - self.startX)//2, self.endY, self.endZ-1)) + self.placeWall((self.startX + (self.endX - self.startX)//2 -1, self.startY, self.startZ+ (self.endZ - self.startZ)//2), (self.startX + (self.endX - self.startX)//2 -1, self.endY, self.endZ)) + self.placeWall((self.startX + (self.endX - self.startX)//2, self.startY, self.startZ+ (self.endZ - self.startZ)//2 -1), (self.endX , self.endY, self.startZ+ (self.endZ - self.startZ)//2 -1)) + self.placeWall((self.endX-1, self.startY, self.startZ), (self.endX-1, self.endY, self.startZ+ (self.endZ - self.startZ)//2)) + + self.placeDoor("east", self.startX + (self.endX -self.startX) // 2 -1 ,self.endZ - (self.endZ - self.startZ)//4 -1,self.startY) + if self.hasGarage: + self.placeGarage((self.endX-1, self.startY, self.startZ +1), (self.endX-1, self.endY, self.startZ+ (self.endZ - self.startZ)//2 -1)) + else : + self.placeGround((self.startX+ (self.endX -self.startX) // 2 , self.startY, self.startZ), (self.endX, self.endY, self.startZ+ (self.endZ - self.startZ)//2), self.grass) + self.placeRoof((self.startX, self.startY, self.startZ), (self.startX + (self.endX - self.startX)//2, self.endY, self.endZ)) + self.placeRoof((self.startX + (self.endX - self.startX)//2, self.startY, self.startZ+ (self.endZ - self.startZ)//2), (self.endX, self.endY, self.endZ)) + self.placeWall((self.startX, self.startY, self.startZ), (self.startX+ (self.endX - self.startX)//2 , self.endY, self.startZ)) + self.placeWall((self.startX, self.startY, self.startZ), (self.startX, self.endY, self.endZ)) + self.placeWall((self.startX, self.startY, self.endZ-1), (self.endX , self.endY, self.endZ-1)) + self.placeWall((self.startX + (self.endX - self.startX)//2, self.startY, self.startZ+ (self.endZ - self.startZ)//2), (self.endX , self.endY, self.startZ+ (self.endZ - self.startZ)//2)) + self.placeWall((self.startX + (self.endX - self.startX)//2 -1, self.startY, self.startZ), (self.startX + (self.endX - self.startX)//2 -1, self.endY, self.startZ+ (self.endZ - self.startZ)//2 )) + self.placeWall((self.endX-1, self.startY, self.startZ+ (self.endZ - self.startZ)//2), (self.endX-1, self.endY, self.endZ)) + + self.placeDoor("east", self.endX - (self.endX -self.startX) // 2 -1 , self.startZ + (self.endZ - self.startZ)//4 ,self.startY) + if self.hasGarage: + self.placeGarage((self.endX-1, self.startY, self.startZ+ (self.endZ - self.startZ)//2 +1), (self.endX-1, self.endY, self.endZ -1)) + + else: + self.houseWithoutGarden(self.houseDirection) + + + def placeDoorBasedOnDirection(self, direction): + if direction in ["north", "south"]: + z = self.startZ if direction == "north" else self.endZ - 1 + if (self.endX - self.startX) % 2 != 0: + self.placeDoor(direction, (self.startX + self.endX)//2, z, self.startY) + else: + self.placeDoor(direction, (self.startX + self.endX)//2, z, self.startY) + self.placeDoor(direction, ((self.startX + self.endX)//2)-1, z, self.startY) + else: + x = self.startX if direction == "west" else self.endX - 1 + if (self.endZ - self.startZ) % 2 != 0: + self.placeDoor(direction, x, (self.startZ + self.endZ)//2, self.startY) + else: + self.placeDoor(direction, x, (self.startZ + self.endZ)//2, self.startY) + self.placeDoor(direction, x, ((self.startZ + self.endZ)//2)-1, self.startY) + + def houseWithoutGarden(self, direction="north"): + self.placeRoof((self.startX, self.startY, self.startZ), (self.endX, self.endY, self.endZ)) + self.placeWall((self.startX, self.startY, self.startZ), (self.endX, self.endY, self.startZ)) + self.placeWall((self.startX, self.startY, self.startZ), (self.startX, self.endY, self.endZ)) + self.placeWall((self.startX, self.startY, self.endZ-1), (self.endX, self.endY, self.endZ-1)) + self.placeWall((self.endX-1, self.startY, self.startZ), (self.endX-1, self.endY, self.endZ)) + + self.placeDoorBasedOnDirection(direction) + + + + + def clear(self): + for x in range(self.startX-1, self.endX+1): + for y in range(self.startY-1, self.endY+1): + for z in range(self.startZ-1, self.endZ+1): + self.editor.placeBlock((x, y, z), air) + +if __name__ == "__main__": + editor = Editor(buffering=True) + buildArea = editor.getBuildArea() + coordinates_min = [min(buildArea.begin[i], buildArea.last[i]) for i in range(3)] + coordinates_max = [max(buildArea.begin[i], buildArea.last[i]) for i in range(3)] + + house = House(editor,coordinates_min[0],coordinates_min[1],coordinates_min[2],coordinates_max[0],coordinates_max[1],coordinates_max[2], style_basique,"east") + + # house.placeHouse() + + house.clear() + editor.flushBuffer() + + + + + + \ No newline at end of file diff --git a/list_block.py b/list_block.py new file mode 100644 index 0000000..af99e90 --- /dev/null +++ b/list_block.py @@ -0,0 +1,70 @@ +from gdpc import Block + + +air = Block('air') + + + + + + + +style_basique={ + 'mur':"white_concrete", + 'sol':"oak_planks", + 'toit':"oak_planks", + 'grass':"grass_block", + 'chemin':"quartz_block", + 'fence':'oak_fence', + 'toit_esca':'oak_stairs', + 'toit_planche':"oak_planks", + 'toit_slab':'oak_slab', + 'glass':"glass", + 'door':'oak_door' + + + } + +style_jungle={ + 'mur':"light_gray_concrete", + 'sol':"acacia_planks", + 'grass':"grass_block", + 'chemin':"podzol", + 'fence':'acacia_fence', + 'toit_esca':'acacia_stairs', + 'toit_planche':"acacia_planks", + 'toit_slab':'acacia_slab', + 'glass':"glass", + 'door':'acacia_door' + + + } +style_end={ + 'mur':"purple_concrete", + 'sol':"crimson_planks", + 'grass':"grass_block", + 'chemin':"amethyst_block", + 'fence':'crimson_fence', + 'toit_esca':'crimson_stairs', + 'toit_planche':"crimson_planks", + 'toit_slab':'crimson_slab', + 'glass':"glass", + 'door':'crimson_door' + + + } + +style_birch={ + 'mur':"yellow_concrete", + 'sol':"birch_planks", + 'grass':"grass_block", + 'chemin':"rooted_dirt", + 'fence':'birch_fence', + 'toit_esca':'birch_stairs', + 'toit_planche':"birch_planks", + 'toit_slab':'birch_slab', + 'glass':"glass", + 'door':'birch_door' + + + } \ No newline at end of file From 0deed441bd3a18314b72dd3ebd78d08f996e1512 Mon Sep 17 00:00:00 2001 From: Eclairsombre Date: Thu, 25 Apr 2024 22:21:39 +0200 Subject: [PATCH 03/18] add optimisation --- House.py | 38 +++++++++++++++++--------------------- 1 file changed, 17 insertions(+), 21 deletions(-) diff --git a/House.py b/House.py index 40b71af..a715fe6 100644 --- a/House.py +++ b/House.py @@ -8,7 +8,8 @@ class House: self.editor = editor self.coordinates_min = coordinates_min self.coordinates_max = coordinates_max - + self.grid = np.zeros((coordinates_max[0], coordinates_max[2]), dtype=bool) # Create a grid of zeros (False) + self.skeleton = [] def createHouseSkeleton(self): @@ -20,6 +21,7 @@ class House: for y in range(z_min, z_max): if i == x_min or i == x_max - 1 or y == z_min or y == z_max - 1: self.editor.placeBlock((i, y_min, y), Block("oak_planks")) + perimeter_width = x_max - x_min perimeter_depth = z_max - z_min @@ -39,37 +41,31 @@ class House: for i in range(0, width-1): for j in range(0, depth-1): self.editor.placeBlock((x + i, y_min, z + j), Block("stone")) - + self.grid[x+i,z+j] = True self.skeleton.append((x, z, width, depth)) block = ["redstone_block", "gold_block", "diamond_block"] for _ in range(3): print("Rectangle n°", _+1, "en cours de création") - while True: - new_width = np.random.randint(width//3, width-2) - new_depth = np.random.randint(depth//3, depth-2) - new_x = np.random.choice([x - new_width, x + width - 1]) - if new_x >= x +width or new_x <= x: - new_z = np.random.choice([z - new_depth + np.random.randint(2,depth), z + depth - 1 -+ np.random.randint(2,depth)]) - else: - new_z = np.random.choice([z - new_depth, z + depth - 1]) - if new_z >= z + depth or new_z <= z: - new_x = np.random.choice([x - new_width + np.random.randint(2,width), x + width - 1 - np.random.randint(2,width)]) + for a in range(1000): + new_width = np.random.randint(width//2, width-2) + new_depth = np.random.randint(depth//2, depth-2) - if new_x + new_width-1 > x_max-1: - new_x = x_max - new_width-1 - if new_z + new_depth-1 > z_max-1: - new_z = z_max - new_depth-1 - - if new_x >= x_min+1 and new_x + new_width <= x_max-1 and new_z >= z_min+1 and new_z + new_depth <= z_max-1 and not self.checkOverlap(new_x, new_z, new_width, new_depth): + new_x = np.random.randint(max(x_min+1, x - new_width), min(x_max-new_width, x + width)) + new_z = np.random.randint(max(z_min+1, z - new_depth), min(z_max-new_depth, z + depth)) + + if not np.any(self.grid[new_x:new_x+new_width, new_z:new_z+new_depth]): for i in range(0, new_width): for j in range(0, new_depth): self.editor.placeBlock((new_x + i, y_min, new_z + j), Block(block[_])) - + self.grid[new_x + i, new_z + j] = True + self.skeleton.append((new_x, new_z, new_width, new_depth)) - break - + break + else: + print("Failed to place rectangle after 1000 attempts.") + def checkOverlap(self, x, z, width, depth): for skeleton in self.skeleton: x_skeleton, z_skeleton, width_skeleton, depth_skeleton = skeleton From baab98fe84286622b564fff518562cecec08c6d0 Mon Sep 17 00:00:00 2001 From: Eclairsombre Date: Fri, 26 Apr 2024 12:32:34 +0200 Subject: [PATCH 04/18] update logique --- House.py | 54 ++++++++++++++++++++++++++++++++++++++---------------- 1 file changed, 38 insertions(+), 16 deletions(-) diff --git a/House.py b/House.py index a715fe6..28a62b0 100644 --- a/House.py +++ b/House.py @@ -13,7 +13,7 @@ class House: self.skeleton = [] def createHouseSkeleton(self): - self.delete() + #self.delete() x_min, y_min, z_min = self.coordinates_min x_max, y_max, z_max = self.coordinates_max @@ -43,19 +43,42 @@ class House: self.editor.placeBlock((x + i, y_min, z + j), Block("stone")) self.grid[x+i,z+j] = True self.skeleton.append((x, z, width, depth)) + print("Coordinates of the corners: ", (x, z), (x, z+depth-1), (x+width-1, z), (x+width-1, z+depth-1)) block = ["redstone_block", "gold_block", "diamond_block"] for _ in range(3): print("Rectangle n°", _+1, "en cours de création") - for a in range(1000): + corners = [(x-1, z-1), (x-1, z+depth-1), (x+width-1, z-1), (x+width-1, z+depth-1)] + around_corners = [(x-1, z),(x, z-1), (x-1, z+depth-2),(x, z+depth-1), (x+width-2, z-1),(x+width-1, z), (x+width-1, z+depth-2),(x+width-2, z+depth-1)] + around_around_corners = [(x-1, z+1), (x+1, z-1), (x-1, z+depth-3), (x+1, z+depth-1), (x+width-3, z-1), (x+width-1, z+1), (x+width-1, z+depth-3), (x+width-3, z+depth-1)] + + corners = corners + around_corners + around_around_corners + print(corners) + for a in range(100000): new_width = np.random.randint(width//2, width-2) new_depth = np.random.randint(depth//2, depth-2) - new_x = np.random.randint(max(x_min+1, x - new_width), min(x_max-new_width, x + width)) - new_z = np.random.randint(max(z_min+1, z - new_depth), min(z_max-new_depth, z + depth)) + new_x = np.random.randint(max(x_min+1, x - new_width ), min(x_max-new_width - 1, x + width )) + new_z = np.random.randint(max(z_min+1, z - new_depth), min(z_max-new_depth - 1, z + depth )) + + + #if (new_x, new_z) in corners or(new_x+new_width-1, new_z) in corners or (new_x, new_z+new_depth-1) in corners or (new_x+new_width-1, new_z+new_depth-1) in corners: + # continue + + # Check if the majority of the small rectangle is adjacent to the first rectangle + adjacent_blocks = 0 + for i in range(new_x, new_x + new_width): + for j in range(new_z, new_z + new_depth): + if self.grid[i-1,j] or self.grid[i+1,j] or self.grid[i,j-1] or self.grid[i,j+1]: + adjacent_blocks += 1 + + if adjacent_blocks < 3: + continue if not np.any(self.grid[new_x:new_x+new_width, new_z:new_z+new_depth]): + print(new_x, new_z, x,z) + print(new_x+ new_width-1, new_z+new_depth-1, x+width-1, z+depth-1) for i in range(0, new_width): for j in range(0, new_depth): self.editor.placeBlock((new_x + i, y_min, new_z + j), Block(block[_])) @@ -66,14 +89,7 @@ class House: else: print("Failed to place rectangle after 1000 attempts.") - def checkOverlap(self, x, z, width, depth): - for skeleton in self.skeleton: - x_skeleton, z_skeleton, width_skeleton, depth_skeleton = skeleton - if x < x_skeleton + width_skeleton and x + width > x_skeleton and z < z_skeleton + depth_skeleton and z + depth > z_skeleton: - return True - - return False - + def delete(self): for x in range(self.coordinates_min[0], self.coordinates_max[0]): for y in range(self.coordinates_min[1], self.coordinates_max[1]): @@ -86,11 +102,17 @@ if __name__ == "__main__": buildArea = editor.getBuildArea() coordinates_min = [min(buildArea.begin[i], buildArea.last[i]) for i in range(3)] coordinates_max = [max(buildArea.begin[i], buildArea.last[i]) for i in range(3)] + - house = House(editor, coordinates_min, coordinates_max) - house.createHouseSkeleton() - - + for i in range(10): + house = House(editor, coordinates_min, coordinates_max) + house.createHouseSkeleton() + print("House n°", i+1, "created") + print('-----------------------------------') + new_coordinates_min =(coordinates_max[0] + 10, coordinates_min[1], coordinates_min[2]) + new_coordinates_max = (coordinates_max[0] + 10 +24, coordinates_max[1], coordinates_max[2]) + coordinates_min = new_coordinates_min + coordinates_max = new_coordinates_max # delete(editor, coordinates_min, coordinates_max) editor.flushBuffer() From 7d073fd5614c6b27a3ae88db992085ba5ceb23c8 Mon Sep 17 00:00:00 2001 From: Eclairsombre Date: Fri, 26 Apr 2024 13:18:06 +0200 Subject: [PATCH 05/18] add wall generation --- House.py | 31 ++++++++++++++++++++++--------- 1 file changed, 22 insertions(+), 9 deletions(-) diff --git a/House.py b/House.py index 28a62b0..741c755 100644 --- a/House.py +++ b/House.py @@ -8,12 +8,11 @@ class House: self.editor = editor self.coordinates_min = coordinates_min self.coordinates_max = coordinates_max - self.grid = np.zeros((coordinates_max[0], coordinates_max[2]), dtype=bool) # Create a grid of zeros (False) - + self.grid = np.zeros((coordinates_max[0], coordinates_max[2]), dtype=[('bool', bool), ('int', int)]) self.skeleton = [] def createHouseSkeleton(self): - #self.delete() + self.delete() x_min, y_min, z_min = self.coordinates_min x_max, y_max, z_max = self.coordinates_max @@ -41,7 +40,7 @@ class House: for i in range(0, width-1): for j in range(0, depth-1): self.editor.placeBlock((x + i, y_min, z + j), Block("stone")) - self.grid[x+i,z+j] = True + self.grid[x+i,z+j] = True,1 self.skeleton.append((x, z, width, depth)) print("Coordinates of the corners: ", (x, z), (x, z+depth-1), (x+width-1, z), (x+width-1, z+depth-1)) @@ -70,19 +69,19 @@ class House: adjacent_blocks = 0 for i in range(new_x, new_x + new_width): for j in range(new_z, new_z + new_depth): - if self.grid[i-1,j] or self.grid[i+1,j] or self.grid[i,j-1] or self.grid[i,j+1]: + if self.grid[i-1,j]['bool'] and self.grid[i-1,j]['int']==1 or self.grid[i+1,j]['bool'] and self.grid[i+1,j]['int']==1 or self.grid[i,j-1]['bool'] and self.grid[i,j-1]['int']==1 or self.grid[i,j+1]['bool'] and self.grid[i,j+1]['int']==1: adjacent_blocks += 1 if adjacent_blocks < 3: continue - if not np.any(self.grid[new_x:new_x+new_width, new_z:new_z+new_depth]): + if not np.any(self.grid[new_x:new_x+new_width, new_z:new_z+new_depth]['bool']): print(new_x, new_z, x,z) print(new_x+ new_width-1, new_z+new_depth-1, x+width-1, z+depth-1) for i in range(0, new_width): for j in range(0, new_depth): self.editor.placeBlock((new_x + i, y_min, new_z + j), Block(block[_])) - self.grid[new_x + i, new_z + j] = True + self.grid[new_x + i, new_z + j] = True,2 self.skeleton.append((new_x, new_z, new_width, new_depth)) break @@ -96,7 +95,20 @@ class House: for z in range(self.coordinates_min[2], self.coordinates_max[2]): self.editor.placeBlock((x, y, z), Block("air")) - + def putWallOnSkeleton(self): + for skeleton in self.skeleton: + x, z, width, depth = skeleton + for i in range(0, width): + for j in range(0, depth): + for y in range(self.coordinates_min[1], self.coordinates_max[1]): + if i == 0 or i == width-1 or j == 0 or j == depth-1: + if not (self.grid[x + i - 1, z + j]['bool'] ) or \ + not (self.grid[x + i + 1, z + j]['bool'] ) or \ + not (self.grid[x + i, z + j - 1]['bool'] ) or \ + not (self.grid[x + i, z + j + 1]['bool'] ): + self.editor.placeBlock((x + i, y, z + j), Block("stone")) + + if __name__ == "__main__": editor = Editor(buffering=True) buildArea = editor.getBuildArea() @@ -104,9 +116,10 @@ if __name__ == "__main__": coordinates_max = [max(buildArea.begin[i], buildArea.last[i]) for i in range(3)] - for i in range(10): + for i in range(1): house = House(editor, coordinates_min, coordinates_max) house.createHouseSkeleton() + house.putWallOnSkeleton() print("House n°", i+1, "created") print('-----------------------------------') new_coordinates_min =(coordinates_max[0] + 10, coordinates_min[1], coordinates_min[2]) From d93c5e09cdb6beb674711836df6a7d86c4c1720a Mon Sep 17 00:00:00 2001 From: Eclairsombre Date: Fri, 26 Apr 2024 16:30:50 +0200 Subject: [PATCH 06/18] update wall generation --- House.py | 49 +++++++++++++++++++++++++++++-------------------- main.py | 2 +- 2 files changed, 30 insertions(+), 21 deletions(-) diff --git a/House.py b/House.py index 741c755..8ee7d46 100644 --- a/House.py +++ b/House.py @@ -21,7 +21,9 @@ class House: if i == x_min or i == x_max - 1 or y == z_min or y == z_max - 1: self.editor.placeBlock((i, y_min, y), Block("oak_planks")) - + + + perimeter_width = x_max - x_min perimeter_depth = z_max - z_min @@ -41,7 +43,7 @@ class House: for j in range(0, depth-1): self.editor.placeBlock((x + i, y_min, z + j), Block("stone")) self.grid[x+i,z+j] = True,1 - self.skeleton.append((x, z, width, depth)) + self.skeleton.append((x, z, width-1, depth-1)) print("Coordinates of the corners: ", (x, z), (x, z+depth-1), (x+width-1, z), (x+width-1, z+depth-1)) block = ["redstone_block", "gold_block", "diamond_block"] @@ -53,10 +55,10 @@ class House: around_around_corners = [(x-1, z+1), (x+1, z-1), (x-1, z+depth-3), (x+1, z+depth-1), (x+width-3, z-1), (x+width-1, z+1), (x+width-1, z+depth-3), (x+width-3, z+depth-1)] corners = corners + around_corners + around_around_corners - print(corners) + for a in range(100000): - new_width = np.random.randint(width//2, width-2) - new_depth = np.random.randint(depth//2, depth-2) + new_width = np.random.randint(5, width-2) + new_depth = np.random.randint(5, depth-2) new_x = np.random.randint(max(x_min+1, x - new_width ), min(x_max-new_width - 1, x + width )) new_z = np.random.randint(max(z_min+1, z - new_depth), min(z_max-new_depth - 1, z + depth )) @@ -76,13 +78,15 @@ class House: continue if not np.any(self.grid[new_x:new_x+new_width, new_z:new_z+new_depth]['bool']): - print(new_x, new_z, x,z) - print(new_x+ new_width-1, new_z+new_depth-1, x+width-1, z+depth-1) for i in range(0, new_width): for j in range(0, new_depth): - self.editor.placeBlock((new_x + i, y_min, new_z + j), Block(block[_])) self.grid[new_x + i, new_z + j] = True,2 + if i == 0 or i == new_width-1 or j == 0 or j == new_depth-1: + continue + else: + self.editor.placeBlock((new_x + i, y_min, new_z + j), Block(block[_])) + self.skeleton.append((new_x, new_z, new_width, new_depth)) break else: @@ -96,19 +100,24 @@ class House: self.editor.placeBlock((x, y, z), Block("air")) def putWallOnSkeleton(self): - for skeleton in self.skeleton: - x, z, width, depth = skeleton - for i in range(0, width): - for j in range(0, depth): - for y in range(self.coordinates_min[1], self.coordinates_max[1]): - if i == 0 or i == width-1 or j == 0 or j == depth-1: - if not (self.grid[x + i - 1, z + j]['bool'] ) or \ - not (self.grid[x + i + 1, z + j]['bool'] ) or \ - not (self.grid[x + i, z + j - 1]['bool'] ) or \ - not (self.grid[x + i, z + j + 1]['bool'] ): + for k in range(len(self.skeleton)): + x, z, width, depth = self.skeleton[k] + if k!= 0: + x+=1 + z+=1 + width-=2 + depth-=2 + for i in range(-1, width+1): + for j in range(-1, depth+1): + for y in range(self.coordinates_min[1]+1, self.coordinates_max[1]): + if i == -1 or i == width or j == -1 or j == depth: + if not (self.grid[x + i, z + j]['bool']) and not (self.grid[x + i, z + j]['int'] == 1) or (self.grid[x + i, z + j]['bool'] and self.grid[x + i, z + j]['int'] == 2): self.editor.placeBlock((x + i, y, z + j), Block("stone")) - - + print( i, y, j, self.grid[x + i, z + j]['bool'],self.grid[x + i, z + j]['int']) + + + + if __name__ == "__main__": editor = Editor(buffering=True) buildArea = editor.getBuildArea() diff --git a/main.py b/main.py index 742c224..29cb455 100644 --- a/main.py +++ b/main.py @@ -5,7 +5,7 @@ import numpy as np editor = Editor(buffering=True) # # Get a block -# block = editor.getBlock((0,48,0)) +block = editor.getBlock((0,48,0)) # # Place a block editor.placeBlock((-5, -58, 0), Block("stone")) From 4a97cad8f92982698137cba141b2e63e9abc8d37 Mon Sep 17 00:00:00 2001 From: Eclairsombre Date: Fri, 26 Apr 2024 16:48:52 +0200 Subject: [PATCH 07/18] Get the wall who are next to the 1 rect --- House.py | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/House.py b/House.py index 8ee7d46..c68b428 100644 --- a/House.py +++ b/House.py @@ -116,7 +116,23 @@ class House: print( i, y, j, self.grid[x + i, z + j]['bool'],self.grid[x + i, z + j]['int']) - + def getAdjacentWalls(self): + main_rect = self.skeleton[0] + x_main, z_main, width_main, depth_main = main_rect + adjacent_walls = [] + + for k in range(1, len(self.skeleton)): + x, z, width, depth = self.skeleton[k] + + walls = [(x, z, x + width-1, z), (x, z, x, z + depth-1), (x, z + depth-1, x + width-1, z + depth-1), (x + width-1, z, x + width-1, z + depth-1)] + for wall in walls: + x1, z1, x2, z2 = wall + if (x_main <= x1 <= x_main + width_main or x_main <= x2 <= x_main + width_main) and (z_main - 1 == z1 or z_main + depth_main + 1 == z1): + adjacent_walls.append(wall) + elif (z_main <= z1 <= z_main + depth_main or z_main <= z2 <= z_main + depth_main) and (x_main - 1 == x1 or x_main + width_main + 1 == x1): + adjacent_walls.append(wall) + + return adjacent_walls if __name__ == "__main__": editor = Editor(buffering=True) @@ -131,6 +147,7 @@ if __name__ == "__main__": house.putWallOnSkeleton() print("House n°", i+1, "created") print('-----------------------------------') + print(house.getAdjacentWalls()) new_coordinates_min =(coordinates_max[0] + 10, coordinates_min[1], coordinates_min[2]) new_coordinates_max = (coordinates_max[0] + 10 +24, coordinates_max[1], coordinates_max[2]) coordinates_min = new_coordinates_min From c376867b3dd0dd81ef2a452fc6feeaa7073ca82e Mon Sep 17 00:00:00 2001 From: Eclairsombre Date: Fri, 26 Apr 2024 17:35:55 +0200 Subject: [PATCH 08/18] add door --- House.py | 49 +++++++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 45 insertions(+), 4 deletions(-) diff --git a/House.py b/House.py index c68b428..e92d0c3 100644 --- a/House.py +++ b/House.py @@ -109,17 +109,19 @@ class House: depth-=2 for i in range(-1, width+1): for j in range(-1, depth+1): - for y in range(self.coordinates_min[1]+1, self.coordinates_max[1]): + for y in range(self.coordinates_min[1], self.coordinates_max[1]): if i == -1 or i == width or j == -1 or j == depth: if not (self.grid[x + i, z + j]['bool']) and not (self.grid[x + i, z + j]['int'] == 1) or (self.grid[x + i, z + j]['bool'] and self.grid[x + i, z + j]['int'] == 2): self.editor.placeBlock((x + i, y, z + j), Block("stone")) - print( i, y, j, self.grid[x + i, z + j]['bool'],self.grid[x + i, z + j]['int']) + #print( i, y, j, self.grid[x + i, z + j]['bool'],self.grid[x + i, z + j]['int']) def getAdjacentWalls(self): main_rect = self.skeleton[0] x_main, z_main, width_main, depth_main = main_rect adjacent_walls = [] + width_main-=1 + depth_main-=1 for k in range(1, len(self.skeleton)): x, z, width, depth = self.skeleton[k] @@ -128,11 +130,49 @@ class House: for wall in walls: x1, z1, x2, z2 = wall if (x_main <= x1 <= x_main + width_main or x_main <= x2 <= x_main + width_main) and (z_main - 1 == z1 or z_main + depth_main + 1 == z1): - adjacent_walls.append(wall) + # Adjust the wall segment to only include the part that is overlapped by the main rectangle + x1 = max(x1, x_main-1) + x2 = min(x2, x_main + width_main+1) + # If there is more than one adjacent block, add it to the list + if abs(x2 - x1) > 1: + adjacent_walls.append((x1, z1, x2, z2)) elif (z_main <= z1 <= z_main + depth_main or z_main <= z2 <= z_main + depth_main) and (x_main - 1 == x1 or x_main + width_main + 1 == x1): - adjacent_walls.append(wall) + # Adjust the wall segment to only include the part that is overlapped by the main rectangle + z1 = max(z1, z_main-1) + z2 = min(z2, z_main + depth_main+1) + # If there is more than one adjacent block, add it to the list + if abs(z2 - z1) > 1: + adjacent_walls.append((x1, z1, x2, z2)) return adjacent_walls + + def placeDoor(self): + walls = self.getAdjacentWalls() + for wall in walls: + x_min, z_min, x_max, z_max = wall + if x_min == x_max: + width = z_max - z_min + if width % 2 != 0: + door_pos = width // 2 + for y in range(self.coordinates_min[1]+1, self.coordinates_min[1]+3): + self.editor.placeBlock((x_min, y, z_min + door_pos), Block("air")) + self.editor.placeBlock((x_min, y, z_min + door_pos+1), Block("air")) + else: + door_pos = width // 2 + for y in range(self.coordinates_min[1]+1, self.coordinates_min[1]+3): + self.editor.placeBlock((x_min, y, z_min + door_pos), Block("air")) + else: + width = x_max - x_min + if width % 2 != 0: + door_pos = width // 2 + for y in range(self.coordinates_min[1]+1, self.coordinates_min[1]+3): + self.editor.placeBlock((x_min + door_pos, y, z_min), Block("air")) + self.editor.placeBlock((x_min + door_pos+1, y, z_min), Block("air")) + + else: + door_pos = width // 2 + for y in range(self.coordinates_min[1]+1, self.coordinates_min[1]+3): + self.editor.placeBlock((x_min + door_pos, y, z_min), Block("air")) if __name__ == "__main__": editor = Editor(buffering=True) @@ -148,6 +188,7 @@ if __name__ == "__main__": print("House n°", i+1, "created") print('-----------------------------------') print(house.getAdjacentWalls()) + house.placeDoor() new_coordinates_min =(coordinates_max[0] + 10, coordinates_min[1], coordinates_min[2]) new_coordinates_max = (coordinates_max[0] + 10 +24, coordinates_max[1], coordinates_max[2]) coordinates_min = new_coordinates_min From 60a2f5a3d62b41bb0bcda5adffd6c7088887dc4f Mon Sep 17 00:00:00 2001 From: Eclairsombre Date: Sun, 28 Apr 2024 13:09:35 +0200 Subject: [PATCH 09/18] roof --- House.py | 157 +++++++++++++++++++++++++++++++++++++--------- TestSkelette.py | 26 ++++++++ grid_skeleton.png | Bin 0 -> 12944 bytes 3 files changed, 154 insertions(+), 29 deletions(-) create mode 100644 TestSkelette.py create mode 100644 grid_skeleton.png diff --git a/House.py b/House.py index e92d0c3..9739939 100644 --- a/House.py +++ b/House.py @@ -1,7 +1,10 @@ +from time import sleep from gdpc import Editor, Block, geometry from list_block import * import numpy as np +from skimage.morphology import skeletonize +import matplotlib.pyplot as plt class House: def __init__(self, editor, coordinates_min, coordinates_max): @@ -11,6 +14,8 @@ class House: self.grid = np.zeros((coordinates_max[0], coordinates_max[2]), dtype=[('bool', bool), ('int', int)]) self.skeleton = [] + self.nbEtage = (coordinates_max[1] - coordinates_min[1]) // 5 + def createHouseSkeleton(self): self.delete() x_min, y_min, z_min = self.coordinates_min @@ -21,13 +26,16 @@ class House: if i == x_min or i == x_max - 1 or y == z_min or y == z_max - 1: self.editor.placeBlock((i, y_min, y), Block("oak_planks")) - + perimeter_width = x_max - x_min perimeter_depth = z_max - z_min - + x_min += 1 + z_min += 1 + x_max -= 1 + z_max -= 1 x = np.random.randint(x_min+1 , x_max-1) z = np.random.randint(z_min+1 , z_max-1 ) @@ -48,6 +56,11 @@ class House: block = ["redstone_block", "gold_block", "diamond_block"] + x_min -= 1 + x_max -= 1 + z_min += 1 + z_max += 1 + for _ in range(3): print("Rectangle n°", _+1, "en cours de création") corners = [(x-1, z-1), (x-1, z+depth-1), (x+width-1, z-1), (x+width-1, z+depth-1)] @@ -95,7 +108,7 @@ class House: def delete(self): for x in range(self.coordinates_min[0], self.coordinates_max[0]): - for y in range(self.coordinates_min[1], self.coordinates_max[1]): + for y in range(self.coordinates_min[1], self.coordinates_max[1]+4): for z in range(self.coordinates_min[2], self.coordinates_max[2]): self.editor.placeBlock((x, y, z), Block("air")) @@ -130,50 +143,134 @@ class House: for wall in walls: x1, z1, x2, z2 = wall if (x_main <= x1 <= x_main + width_main or x_main <= x2 <= x_main + width_main) and (z_main - 1 == z1 or z_main + depth_main + 1 == z1): - # Adjust the wall segment to only include the part that is overlapped by the main rectangle x1 = max(x1, x_main-1) x2 = min(x2, x_main + width_main+1) - # If there is more than one adjacent block, add it to the list if abs(x2 - x1) > 1: adjacent_walls.append((x1, z1, x2, z2)) elif (z_main <= z1 <= z_main + depth_main or z_main <= z2 <= z_main + depth_main) and (x_main - 1 == x1 or x_main + width_main + 1 == x1): - # Adjust the wall segment to only include the part that is overlapped by the main rectangle z1 = max(z1, z_main-1) z2 = min(z2, z_main + depth_main+1) - # If there is more than one adjacent block, add it to the list if abs(z2 - z1) > 1: adjacent_walls.append((x1, z1, x2, z2)) return adjacent_walls + + + def placeDoor(self): walls = self.getAdjacentWalls() for wall in walls: - x_min, z_min, x_max, z_max = wall - if x_min == x_max: - width = z_max - z_min - if width % 2 != 0: - door_pos = width // 2 - for y in range(self.coordinates_min[1]+1, self.coordinates_min[1]+3): - self.editor.placeBlock((x_min, y, z_min + door_pos), Block("air")) - self.editor.placeBlock((x_min, y, z_min + door_pos+1), Block("air")) + for i in range(self.nbEtage): + x_min, z_min, x_max, z_max = wall + if x_min == x_max: + width = z_max - z_min + if width % 2 != 0: + door_pos = width // 2 + for y in range(self.coordinates_min[1]+1+i*4, self.coordinates_min[1]+3+i*4): + self.editor.placeBlock((x_min, y, z_min + door_pos), Block("air")) + self.editor.placeBlock((x_min, y, z_min + door_pos+1), Block("air")) + else: + door_pos = width // 2 + for y in range(self.coordinates_min[1]+1+i*4 , self.coordinates_min[1]+3+i*4): + self.editor.placeBlock((x_min, y, z_min + door_pos), Block("air")) else: - door_pos = width // 2 - for y in range(self.coordinates_min[1]+1, self.coordinates_min[1]+3): - self.editor.placeBlock((x_min, y, z_min + door_pos), Block("air")) - else: - width = x_max - x_min - if width % 2 != 0: - door_pos = width // 2 - for y in range(self.coordinates_min[1]+1, self.coordinates_min[1]+3): - self.editor.placeBlock((x_min + door_pos, y, z_min), Block("air")) - self.editor.placeBlock((x_min + door_pos+1, y, z_min), Block("air")) + width = x_max - x_min + if width % 2 != 0: + door_pos = width // 2 + for y in range(self.coordinates_min[1]+1+i*4, self.coordinates_min[1]+3+i*4): + self.editor.placeBlock((x_min + door_pos, y, z_min), Block("air")) + self.editor.placeBlock((x_min + door_pos+1, y, z_min), Block("air")) + else: + door_pos = width // 2 + for y in range(self.coordinates_min[1]+1+i*4, self.coordinates_min[1]+3+i*4): + self.editor.placeBlock((x_min + door_pos, y, z_min), Block("air")) + + def placeRoof(self): + for k in range(len(self.skeleton)-1, -1, -1): + x, z, width, depth = self.skeleton[k] + + if k!= 0: + x+=1 + z+=1 + width-=2 + depth-=2 + n=1 + else: + n=2 + for i in range(-1, width+1): + for j in range(-1, depth+1): + if widthYCZHP@vJ7lE(5@B93oUwMM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28 Apr 2024 13:11:04 +0200 Subject: [PATCH 10/18] update --- House.py | 23 ++--------------------- 1 file changed, 2 insertions(+), 21 deletions(-) diff --git a/House.py b/House.py index 9739939..903d04a 100644 --- a/House.py +++ b/House.py @@ -210,18 +210,7 @@ class House: self.editor.placeBlock((x + i, self.coordinates_max[1]+n, z + j), Block("blackstone_slab",{"type":"bottom"})) if width Date: Sun, 28 Apr 2024 19:27:38 +0200 Subject: [PATCH 11/18] update roof --- House.py | 249 ++++++++++++++++++++++++++++++++++++++++++++++++------- 1 file changed, 220 insertions(+), 29 deletions(-) diff --git a/House.py b/House.py index 903d04a..2376ac4 100644 --- a/House.py +++ b/House.py @@ -4,6 +4,7 @@ from gdpc import Editor, Block, geometry from list_block import * import numpy as np from skimage.morphology import skeletonize +import math import matplotlib.pyplot as plt class House: @@ -14,8 +15,14 @@ class House: self.grid = np.zeros((coordinates_max[0], coordinates_max[2]), dtype=[('bool', bool), ('int', int)]) self.skeleton = [] + size = [(coordinates_max[i] - coordinates_min[i]) + 10 for i in range(3)] + + # Créer le tableau + self.grid3d = np.zeros(size, dtype=[('bool', bool), ('int', int)]) + self.nbEtage = (coordinates_max[1] - coordinates_min[1]) // 5 + def createHouseSkeleton(self): self.delete() x_min, y_min, z_min = self.coordinates_min @@ -41,17 +48,22 @@ class House: width = perimeter_width // 2 depth = perimeter_depth // 2 + height = y_max - y_min if x + width-1 > x_max-1: x = x_max - width-1 if z + depth-1 > z_max-1: z = z_max - depth-1 + + x_plan3d = x - x_min + z_plan3d = z - z_min for i in range(0, width-1): for j in range(0, depth-1): self.editor.placeBlock((x + i, y_min, z + j), Block("stone")) self.grid[x+i,z+j] = True,1 - self.skeleton.append((x, z, width-1, depth-1)) + self.grid3d[x_plan3d+i,0,z_plan3d+j] = True,1 + self.skeleton.append((x, z, width-1, depth-1, height)) print("Coordinates of the corners: ", (x, z), (x, z+depth-1), (x+width-1, z), (x+width-1, z+depth-1)) block = ["redstone_block", "gold_block", "diamond_block"] @@ -63,11 +75,7 @@ class House: for _ in range(3): print("Rectangle n°", _+1, "en cours de création") - corners = [(x-1, z-1), (x-1, z+depth-1), (x+width-1, z-1), (x+width-1, z+depth-1)] - around_corners = [(x-1, z),(x, z-1), (x-1, z+depth-2),(x, z+depth-1), (x+width-2, z-1),(x+width-1, z), (x+width-1, z+depth-2),(x+width-2, z+depth-1)] - around_around_corners = [(x-1, z+1), (x+1, z-1), (x-1, z+depth-3), (x+1, z+depth-1), (x+width-3, z-1), (x+width-1, z+1), (x+width-1, z+depth-3), (x+width-3, z+depth-1)] - corners = corners + around_corners + around_around_corners for a in range(100000): new_width = np.random.randint(5, width-2) @@ -77,10 +85,7 @@ class House: new_z = np.random.randint(max(z_min+1, z - new_depth), min(z_max-new_depth - 1, z + depth )) - #if (new_x, new_z) in corners or(new_x+new_width-1, new_z) in corners or (new_x, new_z+new_depth-1) in corners or (new_x+new_width-1, new_z+new_depth-1) in corners: - # continue - - # Check if the majority of the small rectangle is adjacent to the first rectangle + adjacent_blocks = 0 for i in range(new_x, new_x + new_width): for j in range(new_z, new_z + new_depth): @@ -91,16 +96,19 @@ class House: continue if not np.any(self.grid[new_x:new_x+new_width, new_z:new_z+new_depth]['bool']): + new_x_plan3d = new_x - x_min + new_z_plan3d = new_z - z_min for i in range(0, new_width): for j in range(0, new_depth): self.grid[new_x + i, new_z + j] = True,2 + self.grid3d[new_x_plan3d + i,0, new_z_plan3d + j] = True,2 if i == 0 or i == new_width-1 or j == 0 or j == new_depth-1: continue else: self.editor.placeBlock((new_x + i, y_min, new_z + j), Block(block[_])) - self.skeleton.append((new_x, new_z, new_width, new_depth)) + self.skeleton.append((new_x, new_z, new_width, new_depth, height)) break else: print("Failed to place rectangle after 1000 attempts.") @@ -108,36 +116,42 @@ class House: def delete(self): for x in range(self.coordinates_min[0], self.coordinates_max[0]): - for y in range(self.coordinates_min[1], self.coordinates_max[1]+4): + for y in range(self.coordinates_min[1], self.coordinates_max[1]+10): for z in range(self.coordinates_min[2], self.coordinates_max[2]): self.editor.placeBlock((x, y, z), Block("air")) def putWallOnSkeleton(self): for k in range(len(self.skeleton)): - x, z, width, depth = self.skeleton[k] + x, z, width, depth, height = self.skeleton[k] + + if k!= 0: x+=1 z+=1 width-=2 depth-=2 + x_plan3d = x - self.coordinates_min[0] + z_plan3d = z - self.coordinates_min[2] for i in range(-1, width+1): for j in range(-1, depth+1): - for y in range(self.coordinates_min[1], self.coordinates_max[1]): + for y in range(0, height): if i == -1 or i == width or j == -1 or j == depth: if not (self.grid[x + i, z + j]['bool']) and not (self.grid[x + i, z + j]['int'] == 1) or (self.grid[x + i, z + j]['bool'] and self.grid[x + i, z + j]['int'] == 2): - self.editor.placeBlock((x + i, y, z + j), Block("stone")) + self.editor.placeBlock((x + i, self.coordinates_min[1] + y, z + j), Block("stone")) + self.grid3d[ x_plan3d+i, y, z_plan3d+j] = True #print( i, y, j, self.grid[x + i, z + j]['bool'],self.grid[x + i, z + j]['int']) def getAdjacentWalls(self): main_rect = self.skeleton[0] - x_main, z_main, width_main, depth_main = main_rect + x_main, z_main, width_main, depth_main, heigt_main = main_rect adjacent_walls = [] width_main-=1 depth_main-=1 for k in range(1, len(self.skeleton)): - x, z, width, depth = self.skeleton[k] + x, z, width, depth, heigt = self.skeleton[k] + walls = [(x, z, x + width-1, z), (x, z, x, z + depth-1), (x, z + depth-1, x + width-1, z + depth-1), (x + width-1, z, x + width-1, z + depth-1)] for wall in walls: @@ -189,26 +203,75 @@ class House: def placeRoof(self): for k in range(len(self.skeleton)-1, -1, -1): - x, z, width, depth = self.skeleton[k] + x, z, width, depth, height = self.skeleton[k] + + if k!= 0: x+=1 z+=1 width-=2 depth-=2 - n=1 + if width < depth: + if width <=5: + n = 1 + elif width <=10: + n = 2 + else: + n = 3 + else: + if depth <=5: + n = 1 + elif depth <=10: + n = 2 + else: + n = 3 else: - n=2 + + if width < depth: + n = width // 4 + else: + n = depth // 4 + + + x_plan3d = x - self.coordinates_min[0] + z_plan3d = z - self.coordinates_min[2] for i in range(-1, width+1): for j in range(-1, depth+1): if width Date: Wed, 12 Jun 2024 13:10:59 +0200 Subject: [PATCH 12/18] adding entrance --- House.py | 149 +++++++++++++++++++++++++++++++++++- temp.py | 227 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 372 insertions(+), 4 deletions(-) create mode 100644 temp.py diff --git a/House.py b/House.py index 2376ac4..257a33d 100644 --- a/House.py +++ b/House.py @@ -8,7 +8,7 @@ import math import matplotlib.pyplot as plt class House: - def __init__(self, editor, coordinates_min, coordinates_max): + def __init__(self, editor, coordinates_min, coordinates_max, direction): self.editor = editor self.coordinates_min = coordinates_min self.coordinates_max = coordinates_max @@ -17,11 +17,12 @@ class House: size = [(coordinates_max[i] - coordinates_min[i]) + 10 for i in range(3)] - # Créer le tableau self.grid3d = np.zeros(size, dtype=[('bool', bool), ('int', int)]) self.nbEtage = (coordinates_max[1] - coordinates_min[1]) // 5 + self.direction = direction + def createHouseSkeleton(self): self.delete() @@ -143,6 +144,7 @@ class House: def getAdjacentWalls(self): + main_rect = self.skeleton[0] x_main, z_main, width_main, depth_main, heigt_main = main_rect adjacent_walls = [] @@ -236,6 +238,33 @@ class House: x_plan3d = x - self.coordinates_min[0] z_plan3d = z - self.coordinates_min[2] + + print(width, depth, n) + + if width < depth: + if n==1: + for i in range(-1,depth+1): + self.editor.placeBlock((x+width//2, self.coordinates_max[1], z+i), Block("blackstone")) + else: + for k in range(n): + for i in range(-1, width+1): + for y in range(-1, depth//2+1): + self.editor.placeBlock((x + i, self.coordinates_max[1]+k, z+y+k+2), Block("blackstone")) + self.editor.placeBlock((x + i, self.coordinates_max[1]+k, z+depth-y-3-k), Block("blackstone")) + else: + if n==1: + for i in range(-1,width+1): + self.editor.placeBlock((x+i, self.coordinates_max[1], z+depth//2), Block("blackstone")) + else: + for k in range(n-1): + for i in range(-1, width+1): + for y in range(-1, depth//2+1): + self.editor.placeBlock((x + i, self.coordinates_max[1]+k, z+y+k+2), Block("blackstone")) + self.editor.placeBlock((x + i, self.coordinates_max[1]+k, z+depth-y-3-k), Block("blackstone")) + + + print('-----------------------------------') + for i in range(-1, width+1): for j in range(-1, depth+1): if width Date: Sat, 15 Jun 2024 00:31:00 +0200 Subject: [PATCH 13/18] window --- House.py | 180 ++++++++++++++++++++++++++++++++++++++++++++++++------- 1 file changed, 157 insertions(+), 23 deletions(-) diff --git a/House.py b/House.py index 257a33d..a04c995 100644 --- a/House.py +++ b/House.py @@ -23,6 +23,8 @@ class House: self.direction = direction + self.entranceWall = None + def createHouseSkeleton(self): self.delete() @@ -242,27 +244,33 @@ class House: print(width, depth, n) if width < depth: - if n==1: + + + if n>1: + for k in range(n-1): + for i in range(-1, depth+1): + for y in range(-1, width//2+1): + self.editor.placeBlock((x + i, self.coordinates_max[1]+k, z+y+k+3), Block("blackstone")) + self.editor.placeBlock((x + i, self.coordinates_max[1]+k, z+depth-y-4-k), Block("blackstone")) + if width%2 == 0: + for i in range(-1, depth+1): + self.editor.placeBlock((x+width//2+1, self.coordinates_max[1]+n-1, z+i), Block("blackstone")) for i in range(-1,depth+1): - self.editor.placeBlock((x+width//2, self.coordinates_max[1], z+i), Block("blackstone")) - else: - for k in range(n): - for i in range(-1, width+1): - for y in range(-1, depth//2+1): - self.editor.placeBlock((x + i, self.coordinates_max[1]+k, z+y+k+2), Block("blackstone")) - self.editor.placeBlock((x + i, self.coordinates_max[1]+k, z+depth-y-3-k), Block("blackstone")) + self.editor.placeBlock((x+width//2, self.coordinates_max[1]+n-1, z+i), Block("blackstone")) + else: - if n==1: - for i in range(-1,width+1): - self.editor.placeBlock((x+i, self.coordinates_max[1], z+depth//2), Block("blackstone")) - else: + if n>1: for k in range(n-1): for i in range(-1, width+1): for y in range(-1, depth//2+1): self.editor.placeBlock((x + i, self.coordinates_max[1]+k, z+y+k+2), Block("blackstone")) self.editor.placeBlock((x + i, self.coordinates_max[1]+k, z+depth-y-3-k), Block("blackstone")) - - + if depth%2 == 0: + for i in range(-1, width+1): + self.editor.placeBlock((x+i, self.coordinates_max[1]+n-1, z+depth//2+1), Block("blackstone")) + for i in range(-1,width+1): + self.editor.placeBlock((x+i, self.coordinates_max[1]+n-1, z+depth//2), Block("blackstone")) + print('-----------------------------------') for i in range(-1, width+1): @@ -528,10 +536,113 @@ class House: self.editor.placeBlock((x + i, self.coordinates_min[1] +4*y, z + j), Block("quartz_block")) self.grid3d[ x_plan3d+i, 4*y, z_plan3d+j] = True + def getNonAdjacentWalls(self): + main_rect = self.skeleton[0] + x_main, z_main, width_main, depth_main, height_main = main_rect + non_adjacent_walls = [] + for k in range(1, len(self.skeleton)): + x, z, width, depth, height = self.skeleton[k] + walls = [(x, z, x + width - 1, z), (x, z, x, z + depth - 1), (x, z + depth - 1, x + width - 1, z + depth - 1), (x + width - 1, z, x + width - 1, z + depth - 1)] + + for wall in walls: + x1, z1, x2, z2 = wall + if not ((x_main <= x1 <= x_main + width_main or x_main <= x2 <= x_main + width_main) and (z_main - 1 == z1 or z_main + depth_main + 1 == z1)) and not ((z_main <= z1 <= z_main + depth_main or z_main <= z2 <= z_main + depth_main) and (x_main - 1 == x1 or x_main + width_main + 1 == x1)): + non_adjacent_walls.append((x1, z1, x2, z2)) + print(non_adjacent_walls) + return non_adjacent_walls + + def getAllExterneWalls(self): + walls = [] + adjacent_walls = self.getAdjacentWalls() + for k in range(0, len(self.skeleton)): + x, z, width, depth, height = self.skeleton[k] + if k == 0: + x -= 1 + z -= 1 + width += 2 + depth += 2 + + walls.append((x, z, x + width - 1, z)) + walls.append((x, z, x, z + depth - 1)) + walls.append((x, z + depth - 1, x + width - 1, z + depth - 1)) + walls.append((x + width - 1, z, x + width - 1, z + depth - 1)) + + walls_to_keep = [] + for wall in walls: + remove_wall = False + for adj_wall in adjacent_walls: + if self.isInsideWall(wall, adj_wall): + remove_wall = True + break + if not remove_wall: + walls_to_keep.append(wall) + + return walls_to_keep + + + def isInsideWall(self, big_wall, small_wall): + x1, z1, x2, z2 = big_wall + x3, z3, x4, z4 = small_wall + if x1 == x2 == x3 == x4: + return x1 == x3 and z1 <= z3 and z4 <= z2 + elif z1 == z2 == z3 == z4: + return z1 == z3 and x1 <= x3 and x4 <= x2 + + + def placeWindowOnWall(self,wall,axis, is_x): + for l in range(self.nbEtage): + if axis%2==0: + if axis == 4: + if is_x: + self.editor.placeBlock((wall[0]+2, self.coordinates_min[1] + 2+l*4, wall[1]), Block("glass_pane")) + self.editor.placeBlock((wall[0]+3, self.coordinates_min[1] + 2+l*4, wall[1]), Block("glass_pane")) + else: + self.editor.placeBlock((wall[0], self.coordinates_min[1] + 2+l*4, wall[1]+3), Block("glass_pane")) + self.editor.placeBlock((wall[0], self.coordinates_min[1] + 2+l*4, wall[1]+2), Block("glass_pane")) + else: + for i in range(0, math.ceil(axis/4)): + if is_x: + self.editor.placeBlock((wall[0]+1+i*4, self.coordinates_min[1] + 2+l*4, wall[1]), Block("glass_pane")) + self.editor.placeBlock((wall[0]+2+i*4, self.coordinates_min[1] + 2+l*4, wall[1]), Block("glass_pane")) + else: + self.editor.placeBlock((wall[0], self.coordinates_min[1] + 2+l*4, wall[1]+1+i*4), Block("glass_pane")) + self.editor.placeBlock((wall[0], self.coordinates_min[1] + 2+l*4, wall[1]+2+i*4), Block("glass_pane")) + else: + if axis<=5: + for i in range(0, axis): + if is_x: + self.editor.placeBlock((wall[0]+1+i, self.coordinates_min[1] + 2+l*4, wall[1]), Block("glass_pane")) + else: + self.editor.placeBlock((wall[0], self.coordinates_min[1] + 2+l*4, wall[1]+1+i), Block("glass_pane")) + else: + for i in range(0, math.ceil(axis/2)): + if is_x: + self.editor.placeBlock((wall[0]+i*2+1, self.coordinates_min[1] + 2+l*4, wall[1]), Block("glass_pane")) + + else: + self.editor.placeBlock((wall[0], self.coordinates_min[1] + 2+l*4, wall[1]+i*2+1), Block("glass_pane")) def placeWindow(self): - pass - + walls = self.getAllExterneWalls() + + + for wall in walls: + + x1, z1, x2, z2 = wall + + + + + x = abs(x2-x1) -1 + z = abs(z2-z1) -1 + + if x1 == x2: + self.placeWindowOnWall(wall, z, False) + elif z1 == z2: + self.placeWindowOnWall(wall, x, True) + + + def placeStairs(self): pass @@ -553,9 +664,11 @@ class House: else: return [] - if wall != self.skeleton[0]: + if closest_wall != self.skeleton[0]: wall = (wall[0]+1, wall[1]+1, wall[2]-2, wall[3]-2) + else: + wall = (wall[0], wall[1], wall[2]-1, wall[3]-1) return wall @@ -563,21 +676,40 @@ class House: def placeEntrance(self): wall = self.WallFacingDirection() + self.entranceWall = wall match self.direction: case "N": if (wall[2] - wall[0]) % 2 != 0: self.editor.placeBlock(((wall[0] + wall[2]) // 2 +1, self.coordinates_min[1]+1, wall[1]-1), Block("air")) self.editor.placeBlock(((wall[0] + wall[2]) // 2 +1, self.coordinates_min[1]+2, wall[1]-1), Block("air")) - print((wall[0] + wall[2]) // 2, self.coordinates_min[1]+1, wall[1]) + print((wall[0] + wall[2]) // 2 +1, self.coordinates_min[1]+1, wall[1]-1) self.editor.placeBlock(((wall[0] + wall[2]) // 2, self.coordinates_min[1]+1, wall[1]-1), Block("air")) self.editor.placeBlock(((wall[0] + wall[2]) // 2, self.coordinates_min[1]+2, wall[1]-1), Block("air")) - print((wall[0] + wall[2]) // 2, self.coordinates_min[1]+1, wall[1]+1) + print((wall[0] + wall[2]) // 2, self.coordinates_min[1]+1, wall[1]-1) case "S": - pass + if (wall[2] - wall[0]) % 2 != 0: + self.editor.placeBlock(((wall[0] + wall[2]) // 2 +1, self.coordinates_min[1]+1, wall[3]+1), Block("air")) + self.editor.placeBlock(((wall[0] + wall[2]) // 2 +1, self.coordinates_min[1]+2, wall[3]+1), Block("air")) + print((wall[0] + wall[2]) // 2 +1, self.coordinates_min[1]+1, wall[3]+1) + self.editor.placeBlock(((wall[0] + wall[2]) // 2, self.coordinates_min[1]+1, wall[3]+1), Block("air")) + self.editor.placeBlock(((wall[0] + wall[2]) // 2, self.coordinates_min[1]+2, wall[3]+1), Block("air")) + print((wall[0] + wall[2]) // 2, self.coordinates_min[1]+1, wall[3]+1) case "E": - pass + if (wall[3] - wall[1]) % 2 != 0: + self.editor.placeBlock((wall[2]+1, self.coordinates_min[1]+1, (wall[1] + wall[3]) // 2 +1), Block("air")) + self.editor.placeBlock((wall[2]+1, self.coordinates_min[1]+2, (wall[1] + wall[3]) // 2 +1), Block("air")) + print(wall[2]+1, self.coordinates_min[1]+1, (wall[1] + wall[3]) // 2 +1) + self.editor.placeBlock((wall[2]+1, self.coordinates_min[1]+1, (wall[1] + wall[3]) // 2), Block("air")) + self.editor.placeBlock((wall[2]+1, self.coordinates_min[1]+2, (wall[1] + wall[3]) // 2), Block("air")) + print(wall[2]+1, self.coordinates_min[1]+1, (wall[1] + wall[3]) // 2) case "W": - pass + if (wall[3] - wall[1]) % 2 != 0: + self.editor.placeBlock((wall[0]-1, self.coordinates_min[1]+1, (wall[1] + wall[3]) // 2 +1), Block("air")) + self.editor.placeBlock((wall[0]-1, self.coordinates_min[1]+2, (wall[1] + wall[3]) // 2 +1), Block("air")) + print(wall[0]-1, self.coordinates_min[1]+1, (wall[1] + wall[3]) // 2 +1) + self.editor.placeBlock((wall[0]-1, self.coordinates_min[1]+1, (wall[1] + wall[3]) // 2), Block("air")) + self.editor.placeBlock((wall[0]-1, self.coordinates_min[1]+2, (wall[1] + wall[3]) // 2), Block("air")) + print(wall[0]-1, self.coordinates_min[1]+1, (wall[1] + wall[3]) // 2) case _: pass @@ -599,8 +731,10 @@ if __name__ == "__main__": house.placeDoor() house.placeRoof() house.putCelling() + + house.placeWindow() house.placeEntrance() - + new_coordinates_min =(coordinates_max[0] + 10, coordinates_min[1], coordinates_min[2]) new_coordinates_max = (coordinates_max[0] + 10 +24, coordinates_max[1], coordinates_max[2]) coordinates_min = new_coordinates_min From 59339a46db885345a4db2e6a2c73c51f2d0bb0fe Mon Sep 17 00:00:00 2001 From: Eclairsombre Date: Sat, 15 Jun 2024 14:31:48 +0200 Subject: [PATCH 14/18] Entrance --- House.py | 481 ++++++++++++++++++++++++++++++++++++------------------- 1 file changed, 318 insertions(+), 163 deletions(-) diff --git a/House.py b/House.py index a04c995..6e4e969 100644 --- a/House.py +++ b/House.py @@ -8,7 +8,7 @@ import math import matplotlib.pyplot as plt class House: - def __init__(self, editor, coordinates_min, coordinates_max, direction): + def __init__(self, editor, coordinates_min, coordinates_max, direction, list_block): self.editor = editor self.coordinates_min = coordinates_min self.coordinates_max = coordinates_max @@ -25,20 +25,31 @@ class House: self.entranceWall = None + self.blocks = list_block + + self.entranceCo = None + + + self.wall = Block(list_block["wall"]) + self.roof = Block(list_block["roof"]) + self.roof_slab = Block(list_block["roof_slab"]) + self.door = Block(list_block["door"]) + self.window = Block(list_block["window"]) + self.entrance = Block(list_block["entrance"]) + self.stairs = Block(list_block["stairs"]) + self.celling = Block(list_block["celling"]) + self.floor = Block(list_block["floor"]) + self.celling_slab = Block(list_block["celling_slab"]) + self.gardenOutline = Block(list_block["garden_outline"]) + self.garden_floor = Block(list_block["garden_floor"]) + + def createHouseSkeleton(self): self.delete() x_min, y_min, z_min = self.coordinates_min x_max, y_max, z_max = self.coordinates_max - - for i in range (x_min, x_max): - for y in range(z_min, z_max): - if i == x_min or i == x_max - 1 or y == z_min or y == z_max - 1: - self.editor.placeBlock((i, y_min, y), Block("oak_planks")) - - - - + perimeter_width = x_max - x_min perimeter_depth = z_max - z_min @@ -63,13 +74,12 @@ class House: for i in range(0, width-1): for j in range(0, depth-1): - self.editor.placeBlock((x + i, y_min, z + j), Block("stone")) + self.editor.placeBlock((x + i, y_min, z + j), self.floor) self.grid[x+i,z+j] = True,1 self.grid3d[x_plan3d+i,0,z_plan3d+j] = True,1 self.skeleton.append((x, z, width-1, depth-1, height)) print("Coordinates of the corners: ", (x, z), (x, z+depth-1), (x+width-1, z), (x+width-1, z+depth-1)) - block = ["redstone_block", "gold_block", "diamond_block"] x_min -= 1 x_max -= 1 @@ -109,7 +119,7 @@ class House: if i == 0 or i == new_width-1 or j == 0 or j == new_depth-1: continue else: - self.editor.placeBlock((new_x + i, y_min, new_z + j), Block(block[_])) + self.editor.placeBlock((new_x + i, y_min, new_z + j), self.floor) self.skeleton.append((new_x, new_z, new_width, new_depth, height)) break @@ -140,7 +150,7 @@ class House: for y in range(0, height): if i == -1 or i == width or j == -1 or j == depth: if not (self.grid[x + i, z + j]['bool']) and not (self.grid[x + i, z + j]['int'] == 1) or (self.grid[x + i, z + j]['bool'] and self.grid[x + i, z + j]['int'] == 2): - self.editor.placeBlock((x + i, self.coordinates_min[1] + y, z + j), Block("stone")) + self.editor.placeBlock((x + i, self.coordinates_min[1] + y, z + j), self.wall) self.grid3d[ x_plan3d+i, y, z_plan3d+j] = True #print( i, y, j, self.grid[x + i, z + j]['bool'],self.grid[x + i, z + j]['int']) @@ -250,26 +260,26 @@ class House: for k in range(n-1): for i in range(-1, depth+1): for y in range(-1, width//2+1): - self.editor.placeBlock((x + i, self.coordinates_max[1]+k, z+y+k+3), Block("blackstone")) - self.editor.placeBlock((x + i, self.coordinates_max[1]+k, z+depth-y-4-k), Block("blackstone")) + self.editor.placeBlock((x + i, self.coordinates_max[1]+k, z+y+k+3), self.roof) + self.editor.placeBlock((x + i, self.coordinates_max[1]+k, z+depth-y-4-k), self.roof) if width%2 == 0: for i in range(-1, depth+1): - self.editor.placeBlock((x+width//2+1, self.coordinates_max[1]+n-1, z+i), Block("blackstone")) + self.editor.placeBlock((x+width//2+1, self.coordinates_max[1]+n-1, z+i), self.roof) for i in range(-1,depth+1): - self.editor.placeBlock((x+width//2, self.coordinates_max[1]+n-1, z+i), Block("blackstone")) + self.editor.placeBlock((x+width//2, self.coordinates_max[1]+n-1, z+i), self.roof) else: if n>1: for k in range(n-1): for i in range(-1, width+1): for y in range(-1, depth//2+1): - self.editor.placeBlock((x + i, self.coordinates_max[1]+k, z+y+k+2), Block("blackstone")) - self.editor.placeBlock((x + i, self.coordinates_max[1]+k, z+depth-y-3-k), Block("blackstone")) + self.editor.placeBlock((x + i, self.coordinates_max[1]+k, z+y+k+2), self.roof) + self.editor.placeBlock((x + i, self.coordinates_max[1]+k, z+depth-y-3-k), self.roof) if depth%2 == 0: for i in range(-1, width+1): - self.editor.placeBlock((x+i, self.coordinates_max[1]+n-1, z+depth//2+1), Block("blackstone")) + self.editor.placeBlock((x+i, self.coordinates_max[1]+n-1, z+depth//2+1), self.roof) for i in range(-1,width+1): - self.editor.placeBlock((x+i, self.coordinates_max[1]+n-1, z+depth//2), Block("blackstone")) + self.editor.placeBlock((x+i, self.coordinates_max[1]+n-1, z+depth//2), self.roof) print('-----------------------------------') @@ -278,43 +288,43 @@ class House: if width Date: Sat, 15 Jun 2024 14:57:34 +0200 Subject: [PATCH 15/18] Stairs --- House.py | 28 ++++++++++++++++++++++++++-- 1 file changed, 26 insertions(+), 2 deletions(-) diff --git a/House.py b/House.py index 6e4e969..0663dc7 100644 --- a/House.py +++ b/House.py @@ -630,9 +630,29 @@ class House: self.placeWindowOnWall(wall, x, True) def placeStairs(self): - pass + x, z, width, depth, height = self.skeleton[0] + x_moy = x + width//2 + z_moy = z + depth//2 + slab_up = Block(self.blocks["stairs_slab"], { "type": "top"}) + slab_down = Block(self.blocks["stairs_slab"], { "type": "bottom"}) + for i in range(0, self.nbEtage-1): + for k in range(3): + for l in range(3): + self.editor.placeBlock((x_moy-1+k, self.coordinates_min[1] + 4*(i+1), z_moy-1+l),Block("air")) - + for j in range(1, 5): + self.editor.placeBlock((x_moy, self.coordinates_min[1] + 4*i+j, z_moy), self.floor) + + self.editor.placeBlock((x_moy-1, self.coordinates_min[1] +1+ 4*i, z_moy-1), slab_down) + self.editor.placeBlock((x_moy, self.coordinates_min[1] +1+ 4*i, z_moy-1), slab_up) + self.editor.placeBlock((x_moy+1, self.coordinates_min[1] +2+ 4*i, z_moy-1), slab_down) + self.editor.placeBlock((x_moy+1, self.coordinates_min[1] +2+ 4*i, z_moy), slab_up) + self.editor.placeBlock((x_moy+1, self.coordinates_min[1] +3+ 4*i, z_moy+1), slab_down) + + self.editor.placeBlock((x_moy, self.coordinates_min[1] +3+ 4*i, z_moy+1), slab_up) + self.editor.placeBlock((x_moy-1, self.coordinates_min[1] +4+ 4*i, z_moy+1), slab_down) + self.editor.placeBlock((x_moy-1, self.coordinates_min[1] +4+ 4*i, z_moy), slab_up) + def WallFacingDirection(self): if self.direction == "N": @@ -867,6 +887,7 @@ if __name__ == "__main__": "window": "glass_pane", "entrance": "oak_door", "stairs": "quartz_stairs", + "stairs_slab": "quartz_slab", "celling": "quartz_block", "floor": "quartz_block", "celling_slab": "quartz_slab", @@ -890,6 +911,9 @@ if __name__ == "__main__": house.placeEntrance() house.placeGardenOutline() + if house.nbEtage > 1: + house.placeStairs() + new_coordinates_min =(coordinates_max[0] + 10, coordinates_min[1], coordinates_min[2]) new_coordinates_max = (coordinates_max[0] + 10 +24, coordinates_max[1], coordinates_max[2]) coordinates_min = new_coordinates_min From 4056807caa7558900f7d170fea412d70b858fad6 Mon Sep 17 00:00:00 2001 From: Eclairsombre Date: Sat, 15 Jun 2024 14:59:33 +0200 Subject: [PATCH 16/18] build function --- House.py | 31 ++++++++++++++++--------------- 1 file changed, 16 insertions(+), 15 deletions(-) diff --git a/House.py b/House.py index 0663dc7..7592325 100644 --- a/House.py +++ b/House.py @@ -873,6 +873,21 @@ class House: else: self.editor.placeBlock((i, y_min-1, y), self.garden_floor) + + + def build(self): + house.createHouseSkeleton() + house.putWallOnSkeleton() + house.placeDoor() + house.placeRoof() + house.putCelling() + house.placeWindow() + house.placeEntrance() + house.placeGardenOutline() + if house.nbEtage > 1: + house.placeStairs() + + if __name__ == "__main__": editor = Editor(buffering=True) buildArea = editor.getBuildArea() @@ -898,21 +913,7 @@ if __name__ == "__main__": for i in range(1): house = House(editor, coordinates_min, coordinates_max,"W", blocks) - house.createHouseSkeleton() - house.putWallOnSkeleton() - print("House n°", i+1, "created") - print('-----------------------------------') - print(house.getAdjacentWalls()) - house.placeDoor() - house.placeRoof() - house.putCelling() - - house.placeWindow() - house.placeEntrance() - house.placeGardenOutline() - - if house.nbEtage > 1: - house.placeStairs() + house.build() new_coordinates_min =(coordinates_max[0] + 10, coordinates_min[1], coordinates_min[2]) new_coordinates_max = (coordinates_max[0] + 10 +24, coordinates_max[1], coordinates_max[2]) From 01059a53bef875d35440ab28ec1220334cd4105b Mon Sep 17 00:00:00 2001 From: Eclairsombre Date: Sat, 15 Jun 2024 15:02:26 +0200 Subject: [PATCH 17/18] clean --- House.py | 2 - HouseBackup.py | 335 ---------------------------------------------- TestSkelette.py | 26 ---- grid_skeleton.png | Bin 12944 -> 0 bytes list_block.py | 70 ---------- temp.py | 227 ------------------------------- 6 files changed, 660 deletions(-) delete mode 100644 HouseBackup.py delete mode 100644 TestSkelette.py delete mode 100644 grid_skeleton.png delete mode 100644 list_block.py delete mode 100644 temp.py diff --git a/House.py b/House.py index 7592325..1452168 100644 --- a/House.py +++ b/House.py @@ -1,9 +1,7 @@ from time import sleep from gdpc import Editor, Block, geometry -from list_block import * import numpy as np -from skimage.morphology import skeletonize import math import matplotlib.pyplot as plt diff --git a/HouseBackup.py b/HouseBackup.py deleted file mode 100644 index 9cf94b0..0000000 --- a/HouseBackup.py +++ /dev/null @@ -1,335 +0,0 @@ -from gdpc import Editor, Block, geometry -from list_block import * -import numpy as np -import math - - -class House : - def __init__(self, editor,startX, startY, startZ, endX, endY, endZ,style,houseDirection="north"): - self.editor = editor - self.startX = startX - self.startY = startY - self.startZ = startZ - self.endX = endX - self.endY = endY - self.endZ = endZ - self.houseDirection = houseDirection - self.hasGarder = True - self.gardenSide = "right" - self.hasGarage = True - - self.wall = style['mur'] - self.ground = style['sol'] - self.grass = style['grass'] - self.path = style['chemin'] - self.fence = style['fence'] - self.glass = style['glass'] - self.door = style['door'] - self.roof = style['toit'] - - def placeGround(self,CoStart, CoEnd,block): - for x in range(CoStart[0], CoEnd[0]): - for z in range(CoStart[2], CoEnd[2]): - self.editor.placeBlock((x, CoStart[1], z), Block(block) ) - - def placeRoof(self,CoStart,CoEnd): - for x in range(CoStart[0], CoEnd[0]): - for z in range(CoStart[2], CoEnd[2]): - self.editor.placeBlock((x, CoEnd[1]-1, z), Block(self.roof)) - - - def placeWall(self,CoStart,CoEnd): - if CoStart[0] == CoEnd[0]: - for y in range(CoStart[1]+1, CoEnd[1]-1): - for z in range(CoStart[2], CoEnd[2]): - self.editor.placeBlock((CoStart[0], y, z), Block(self.wall)) - CoStart = (CoStart[0],CoStart[1],CoStart[2]+1) - CoEnd = (CoEnd[0],CoEnd[1],CoEnd[2]-1) - elif CoStart[2] == CoEnd[2]: - for y in range(CoStart[1]+1, CoEnd[1]-1): - for x in range(CoStart[0], CoEnd[0]): - self.editor.placeBlock((x, y, CoStart[2]), Block(self.wall)) - CoStart = (CoStart[0]+1,CoStart[1],CoStart[2]) - CoEnd = (CoEnd[0]-1,CoEnd[1],CoEnd[2]) - - self.placeWindow(CoStart,CoEnd) - - - - - def placeDoor(self, direction="north", x=0, z=0, y=0): - door_directions = { - "south": {"facing": "north", "half": "lower"}, - "north": {"facing": "south", "half": "lower"}, - "east": {"facing": "west", "half": "lower"}, - "west": {"facing": "east", "half": "lower"} - } - - door_properties = door_directions.get(direction) - - if door_properties: - self.editor.placeBlock((x, y + 1, z), Block(self.door, door_properties)) - self.editor.placeBlock((x, y + 2, z), Block(self.door, {"facing": door_properties["facing"], "half": "upper"})) - self.doorDirection = direction - - def placeWindow(self, CoStart, CoEnd): - x = abs(CoEnd[0] - CoStart[0]) - z = abs(CoEnd[2] - CoStart[2]) - type = Block(self.glass) - - def placeBlock(axis, is_x_axis): - print(axis, is_x_axis) - if axis % 2 == 0: - if axis == 4: - if is_x_axis: - self.editor.placeBlock((CoStart[0] + 1, CoStart[1] + 2, CoStart[2]), type) - self.editor.placeBlock((CoStart[0] + 2, CoStart[1] + 2, CoStart[2]), type) - else: - self.editor.placeBlock((CoStart[0], CoStart[1] + 2, CoStart[2] + 1), type) - self.editor.placeBlock((CoStart[0], CoStart[1] + 2, CoStart[2] + 2), type) - else: - for i in range(axis // 2): - if i % 2 == 0: - if is_x_axis: - self.editor.placeBlock((CoStart[0] + i * 2 + 1, CoStart[1] + 2, CoStart[2]), type) - self.editor.placeBlock((CoStart[0] + i * 2 + 2, CoStart[1] + 2, CoStart[2]), type) - else: - self.editor.placeBlock((CoStart[0], CoStart[1] + 2, CoStart[2] + 1 + i * 2), type) - self.editor.placeBlock((CoStart[0], CoStart[1] + 2, CoStart[2] + i * 2 + 2), type) - else: - if axis <= 5: - for i in range(axis): - if is_x_axis: - self.editor.placeBlock((CoStart[0] + i, CoStart[1] + 2, CoStart[2]), type) - else: - self.editor.placeBlock((CoStart[0], CoStart[1] + 2, CoStart[2] + i), type) - else: - for i in range(axis // 3): - if 3 * (i + 1) + i > abs(CoEnd[2] - CoStart[2]): - break - else: - if is_x_axis: - self.editor.placeBlock((CoStart[0], CoStart[1] + 2, CoStart[2] + i * 4), type) - self.editor.placeBlock((CoStart[0], CoStart[1] + 2, CoStart[2] + i * 4 + 1), type) - self.editor.placeBlock((CoStart[0], CoStart[1] + 2, CoStart[2] + i * 4 + 2), type) - else: - self.editor.placeBlock((CoStart[0], CoStart[1] + 2, CoStart[2] + i * 4), type) - self.editor.placeBlock((CoStart[0], CoStart[1] + 2, CoStart[2] + i * 4 + 1), type) - self.editor.placeBlock((CoStart[0], CoStart[1] + 2, CoStart[2] + i * 4 + 2), type) - - if CoStart[0] == CoEnd[0]: - placeBlock(z, False) - - if CoStart[2] == CoEnd[2]: - placeBlock(x, True) - - - - def clearInside(self): - for x in range(self.startX+1, self.endX): - for y in range(self.startY+1, self.endY): - for z in range(self.startZ+1, self.endZ): - self.editor.placeBlock((x, y, z), air) - - - def deleteWall(self,CoStart,CoEnd): - if CoStart[0] == CoEnd[0]: - for y in range(CoStart[1]+1, CoEnd[1]-1): - for z in range(CoStart[2], CoEnd[2]): - self.editor.placeBlock((CoStart[0], y, z), air) - elif CoStart[2] == CoEnd[2]: - for y in range(CoStart[1]+1, CoEnd[1]-1): - for x in range(CoStart[0], CoEnd[0]): - self.editor.placeBlock((x, y, CoStart[2]), air) - - - def placeGarage(self,CoStart,CoEnd): - self.deleteWall(CoStart,CoEnd) - - - - - - - def placeHouse(self): - self.clear() - self.clearInside() - self.placeGround((self.startX, self.startY, self.startZ), (self.endX, self.endY, self.endZ),self.ground) - - if self.hasGarder: - if self.houseDirection == "north" : - if self.gardenSide == "left": - self.placeGround((self.startX+ (self.endX - self.startX)//2, self.startY, self.startZ), (self.endX, self.endY, self.startZ + (self.endZ - self.startZ)//2), self.grass) - self.placeRoof((self.startX, self.startY, self.startZ), (self.endX - (self.endX - self.startX)//2, self.endY, self.endZ)) - self.placeRoof((self.startX + (self.endX - self.startX)//2, self.startY, self.startZ + (self.endZ - self.startZ)//2), (self.endX, self.endY, self.endZ)) - self.placeWall((self.startX, self.startY, self.startZ), (self.startX +(self.endX - self.startX)//2 , self.endY, self.startZ)) - self.placeWall((self.startX, self.startY, self.startZ), (self.startX, self.endY, self.endZ )) - self.placeWall((self.startX, self.startY, self.endZ-1), (self.endX , self.endY, self.endZ-1)) - self.placeWall((self.endX-1, self.startY, self.startZ+ (self.endZ - self.startZ)//2), (self.endX-1, self.endY, self.endZ)) - self.placeWall((self.startX + (self.endX - self.startX)//2 , self.startY, self.startZ+ (self.endZ - self.startZ)//2), (self.endX , self.endY, self.startZ+ (self.endZ - self.startZ)//2)) - self.placeWall((self.startX + (self.endX - self.startX)//2 -1, self.startY, self.startZ), (self.startX + (self.endX - self.startX)//2 -1, self.endY, self.startZ+ (self.endZ - self.startZ)//2 )) - self.placeDoor("north", self.endX - (self.endX -self.startX) // 4 -1 , (self.startZ + self.endZ) //2,self.startY) - if self.hasGarage: - self.placeGarage((self.startX+1, self.startY, self.startZ), (self.startX +(self.endX - self.startX)//2 -1 , self.endY, self.startZ)) - - else: - self.placeGround((self.startX, self.startY, self.startZ), (self.startX + (self.endX-self.startX)//2, self.endY, self.startZ + (self.endZ - self.startZ)//2), self.grass) - self.placeRoof((self.endX- (self.endX - self.startX)//2, self.startY, self.startZ), (self.endX , self.endY, self.endZ)) - self.placeRoof((self.startX , self.startY, self.startZ + (self.endZ - self.startZ)//2), (self.endX - (self.endX - self.startX)//2, self.endY, self.endZ)) - self.placeWall((self.startX, self.startY, self.startZ+ (self.endZ - self.startZ)//2), (self.endX - (self.endX - self.startX)//2, self.endY, self.startZ+ (self.endZ - self.startZ)//2)) - self.placeWall((self.startX, self.startY, self.startZ+ (self.endZ - self.startZ)//2), (self.startX, self.endY, self.endZ )) - self.placeWall((self.startX, self.startY, self.endZ-1), (self.endX , self.endY, self.endZ-1)) - self.placeWall((self.endX-1, self.startY, self.startZ), (self.endX-1, self.endY, self.endZ)) - self.placeWall((self.startX+ (self.endX - self.startX)//2, self.startY, self.startZ), (self.endX, self.endY, self.startZ)) - self.placeWall((self.startX+ (self.endX - self.startX)//2, self.startY, self.startZ), (self.startX+ (self.endX - self.startX)//2, self.endY, self.startZ+ (self.endZ - self.startZ)//2)) - self.placeDoor("north", self.startX + (self.endX -self.startX) // 4 , (self.startZ + self.endZ) //2,self.startY) - if self.hasGarage: - self.placeGarage((self.startX+ (self.endX - self.startX)//2 +1, self.startY, self.startZ), (self.endX-1, self.endY, self.startZ)) - - elif self.houseDirection == "south": - if self.gardenSide == "left": - self.placeGround((self.startX , self.startY, self.startZ + (self.endZ - self.startZ)//2), (self.startX+ (self.endX - self.startX)//2, self.endY, self.endZ), self.grass) - self.placeRoof((self.startX, self.startY, self.startZ), (self.endX, self.endY, self.startZ + (self.endZ - self.startZ)//2)) - self.placeRoof((self.startX + (self.endX - self.startX)//2, self.startY, self.startZ), (self.endX, self.endY, self.endZ)) - self.placeWall((self.startX, self.startY, self.startZ), (self.endX , self.endY, self.startZ)) - self.placeWall((self.startX, self.startY, self.startZ), (self.startX , self.endY, self.startZ + (self.endZ - self.startZ)//2)) - self.placeWall((self.startX, self.startY, self.startZ + (self.endZ - self.startZ)//2 -1), (self.startX + (self.endX - self.startX)//2 , self.endY, self.startZ + (self.endZ - self.startZ)//2 -1)) - self.placeWall((self.startX + (self.endX - self.startX)//2, self.startY, self.endZ-1), (self.endX , self.endY, self.endZ-1)) - self.placeWall((self.startX + (self.endX - self.startX)//2, self.startY, self.startZ + (self.endZ - self.startZ)//2), (self.startX + (self.endX - self.startX)//2, self.endY, self.endZ)) - self.placeWall((self.endX-1, self.startY, self.startZ), (self.endX-1, self.endY, self.endZ)) - - self.placeDoor("south", self.startX + (self.endX -self.startX) // 4 , (self.startZ + self.endZ) //2 -1,self.startY) - if self.hasGarage: - self.placeGarage((self.startX+1, self.startY, self.startZ + (self.endZ - self.startZ)//2 +1), (self.startX +(self.endX - self.startX)//2 -1, self.endY, self.endZ -1)) - - else: - self.placeGround((self.startX + (self.endX - self.startX)//2, self.startY, self.startZ+ (self.endZ - self.startZ)//2), (self.endX, self.endY, self.endZ), self.grass) - self.placeRoof((self.startX, self.startY, self.startZ), (self.startX+(self.endX - self.startX)//2 , self.endY, self.endZ)) - self.placeRoof((self.startX + (self.endX - self.startX)//2, self.startY, self.startZ), (self.endX, self.endY, self.startZ+(self.endZ - self.startZ)//2)) - self.placeWall((self.startX, self.startY, self.startZ), (self.endX , self.endY, self.startZ)) - self.placeWall((self.startX, self.startY, self.startZ), (self.startX , self.endY, self.endZ)) - self.placeWall((self.startX, self.startY, self.endZ-1), (self.startX + (self.endX - self.startX)//2 , self.endY, self.endZ-1)) - self.placeWall((self.startX + (self.endX - self.startX)//2 -1, self.startY, self.startZ + (self.endZ - self.startZ)//2), (self.startX + (self.endX - self.startX)//2 -1, self.endY, self.endZ )) - self.placeWall((self.startX + (self.endX - self.startX)//2, self.startY, self.startZ + (self.endZ - self.startZ)//2 -1), (self.endX , self.endY, self.startZ + (self.endZ - self.startZ)//2 -1)) - self.placeWall((self.endX -1, self.startY, self.startZ ), (self.endX -1, self.endY, self.startZ+ (self.endZ - self.startZ)//2)) - - - self.placeDoor("south", self.endX - (self.endX -self.startX) // 4 -1 , (self.startZ + self.endZ) //2 -1,self.startY) - if self.hasGarage: - self.placeGarage((self.startX+ (self.endX - self.startX)//2 +1, self.startY, self.startZ + (self.endZ - self.startZ)//2 +1), (self.endX-1, self.endY, self.endZ -1)) - - elif self.houseDirection == "west": - if self.gardenSide == "left": - self.placeGround((self.startX, self.startY, self.startZ), (self.startX + (self.endX - self.startX)//2, self.endY, self.startZ+ (self.endZ - self.startZ)//2), self.grass) - self.placeRoof((self.startX + (self.endX - self.startX)//2, self.startY, self.startZ), (self.endX, self.endY, self.endZ)) - self.placeRoof((self.startX, self.startY, self.startZ+ (self.endZ - self.startZ)//2), (self.startX + (self.endX - self.startX)//2, self.endY, self.endZ)) - self.placeWall((self.startX+ (self.endX - self.startX)//2, self.startY, self.startZ), (self.endX, self.endY, self.startZ)) - self.placeWall((self.startX+ (self.endX - self.startX)//2, self.startY, self.startZ), (self.startX+ (self.endX - self.startX)//2, self.endY, self.startZ+ (self.endZ - self.startZ)//2)) - self.placeWall((self.endX-1, self.startY, self.startZ), (self.endX-1, self.endY, self.endZ)) - self.placeWall((self.startX, self.startY, self.startZ+ (self.endZ - self.startZ)//2), (self.startX+ (self.endX - self.startX)//2, self.endY, self.startZ+ (self.endZ - self.startZ)//2)) - self.placeWall((self.startX, self.startY, self.startZ+ (self.endZ - self.startZ)//2), (self.startX, self.endY, self.endZ)) - self.placeWall((self.startX, self.startY, self.endZ-1), (self.endX, self.endY, self.endZ-1)) - self.placeDoor("west", self.endX - (self.endX -self.startX) // 2 , self.startZ + (self.endZ - self.startZ)//4 ,self.startY) - if self.hasGarage: - self.placeGarage((self.startX, self.startY, self.startZ+ (self.endZ - self.startZ)//2 +1), (self.startX , self.endY, self.endZ -1)) - else: - self.placeGround((self.startX, self.startY, self.startZ+ (self.endZ - self.startZ)//2 ), (self.startX+ (self.endX-self.startX)//2, self.endY, self.endZ), self.grass) - self.placeRoof((self.startX + (self.endX - self.startX)//2, self.startY, self.startZ+ (self.endZ - self.startZ)//2), (self.endX, self.endY, self.endZ)) - self.placeRoof((self.startX, self.startY, self.startZ), (self.endX, self.endY, self.startZ+ (self.endZ - self.startZ)//2)) - self.placeWall((self.startX, self.startY, self.startZ+ (self.endZ - self.startZ)//2 -1), (self.startX+ (self.endX - self.startX)//2, self.endY, self.startZ+ (self.endZ - self.startZ)//2 -1)) - self.placeWall((self.startX, self.startY, self.startZ), (self.endX, self.endY, self.startZ)) - self.placeWall((self.startX, self.startY, self.startZ), (self.startX, self.endY, self.startZ+ (self.endZ - self.startZ)//2)) - self.placeWall((self.startX + (self.endX - self.startX)//2, self.startY, self.endZ-1), (self.endX, self.endY, self.endZ-1)) - self.placeWall((self.startX + (self.endX - self.startX)//2, self.startY, self.startZ+ (self.endZ - self.startZ)//2), (self.startX + (self.endX - self.startX)//2, self.endY, self.endZ)) - self.placeWall((self.endX-1, self.startY, self.startZ), (self.endX-1, self.endY, self.endZ)) - - self.placeDoor("west", self.startX + (self.endX -self.startX) // 2 , self.endZ - (self.endZ - self.startZ)//4 -1,self.startY) - if self.hasGarage: - self.placeGarage((self.startX, self.startY, self.startZ+1), (self.startX, self.endY, self.startZ+ (self.endZ - self.startZ)//2 -1)) - - elif self.houseDirection == "east": - if self.gardenSide == "left": - self.placeGround((self.startX + (self.endX - self.startX)//2, self.startY, self.startZ+ (self.endZ - self.startZ)//2), (self.endX , self.endY, self.endZ, self.grass), self.grass) - self.placeRoof((self.startX, self.startY, self.startZ), (self.startX + (self.endX - self.startX)//2, self.endY, self.endZ)) - self.placeRoof((self.startX + (self.endX - self.startX)//2, self.startY, self.startZ), (self.endX, self.endY, self.startZ+ (self.endZ - self.startZ)//2)) - self.placeWall((self.startX, self.startY, self.startZ), (self.endX , self.endY, self.startZ)) - self.placeWall((self.startX, self.startY, self.startZ), (self.startX, self.endY, self.endZ)) - self.placeWall((self.startX, self.startY, self.endZ-1), (self.startX + (self.endX - self.startX)//2, self.endY, self.endZ-1)) - self.placeWall((self.startX + (self.endX - self.startX)//2 -1, self.startY, self.startZ+ (self.endZ - self.startZ)//2), (self.startX + (self.endX - self.startX)//2 -1, self.endY, self.endZ)) - self.placeWall((self.startX + (self.endX - self.startX)//2, self.startY, self.startZ+ (self.endZ - self.startZ)//2 -1), (self.endX , self.endY, self.startZ+ (self.endZ - self.startZ)//2 -1)) - self.placeWall((self.endX-1, self.startY, self.startZ), (self.endX-1, self.endY, self.startZ+ (self.endZ - self.startZ)//2)) - - self.placeDoor("east", self.startX + (self.endX -self.startX) // 2 -1 ,self.endZ - (self.endZ - self.startZ)//4 -1,self.startY) - if self.hasGarage: - self.placeGarage((self.endX-1, self.startY, self.startZ +1), (self.endX-1, self.endY, self.startZ+ (self.endZ - self.startZ)//2 -1)) - else : - self.placeGround((self.startX+ (self.endX -self.startX) // 2 , self.startY, self.startZ), (self.endX, self.endY, self.startZ+ (self.endZ - self.startZ)//2), self.grass) - self.placeRoof((self.startX, self.startY, self.startZ), (self.startX + (self.endX - self.startX)//2, self.endY, self.endZ)) - self.placeRoof((self.startX + (self.endX - self.startX)//2, self.startY, self.startZ+ (self.endZ - self.startZ)//2), (self.endX, self.endY, self.endZ)) - self.placeWall((self.startX, self.startY, self.startZ), (self.startX+ (self.endX - self.startX)//2 , self.endY, self.startZ)) - self.placeWall((self.startX, self.startY, self.startZ), (self.startX, self.endY, self.endZ)) - self.placeWall((self.startX, self.startY, self.endZ-1), (self.endX , self.endY, self.endZ-1)) - self.placeWall((self.startX + (self.endX - self.startX)//2, self.startY, self.startZ+ (self.endZ - self.startZ)//2), (self.endX , self.endY, self.startZ+ (self.endZ - self.startZ)//2)) - self.placeWall((self.startX + (self.endX - self.startX)//2 -1, self.startY, self.startZ), (self.startX + (self.endX - self.startX)//2 -1, self.endY, self.startZ+ (self.endZ - self.startZ)//2 )) - self.placeWall((self.endX-1, self.startY, self.startZ+ (self.endZ - self.startZ)//2), (self.endX-1, self.endY, self.endZ)) - - self.placeDoor("east", self.endX - (self.endX -self.startX) // 2 -1 , self.startZ + (self.endZ - self.startZ)//4 ,self.startY) - if self.hasGarage: - self.placeGarage((self.endX-1, self.startY, self.startZ+ (self.endZ - self.startZ)//2 +1), (self.endX-1, self.endY, self.endZ -1)) - - else: - self.houseWithoutGarden(self.houseDirection) - - - def placeDoorBasedOnDirection(self, direction): - if direction in ["north", "south"]: - z = self.startZ if direction == "north" else self.endZ - 1 - if (self.endX - self.startX) % 2 != 0: - self.placeDoor(direction, (self.startX + self.endX)//2, z, self.startY) - else: - self.placeDoor(direction, (self.startX + self.endX)//2, z, self.startY) - self.placeDoor(direction, ((self.startX + self.endX)//2)-1, z, self.startY) - else: - x = self.startX if direction == "west" else self.endX - 1 - if (self.endZ - self.startZ) % 2 != 0: - self.placeDoor(direction, x, (self.startZ + self.endZ)//2, self.startY) - else: - self.placeDoor(direction, x, (self.startZ + self.endZ)//2, self.startY) - self.placeDoor(direction, x, ((self.startZ + self.endZ)//2)-1, self.startY) - - def houseWithoutGarden(self, direction="north"): - self.placeRoof((self.startX, self.startY, self.startZ), (self.endX, self.endY, self.endZ)) - self.placeWall((self.startX, self.startY, self.startZ), (self.endX, self.endY, self.startZ)) - self.placeWall((self.startX, self.startY, self.startZ), (self.startX, self.endY, self.endZ)) - self.placeWall((self.startX, self.startY, self.endZ-1), (self.endX, self.endY, self.endZ-1)) - self.placeWall((self.endX-1, self.startY, self.startZ), (self.endX-1, self.endY, self.endZ)) - - self.placeDoorBasedOnDirection(direction) - - - - - def clear(self): - for x in range(self.startX-1, self.endX+1): - for y in range(self.startY-1, self.endY+1): - for z in range(self.startZ-1, self.endZ+1): - self.editor.placeBlock((x, y, z), air) - -if __name__ == "__main__": - editor = Editor(buffering=True) - buildArea = editor.getBuildArea() - coordinates_min = [min(buildArea.begin[i], buildArea.last[i]) for i in range(3)] - coordinates_max = [max(buildArea.begin[i], buildArea.last[i]) for i in range(3)] - - house = House(editor,coordinates_min[0],coordinates_min[1],coordinates_min[2],coordinates_max[0],coordinates_max[1],coordinates_max[2], style_basique,"east") - - # house.placeHouse() - - house.clear() - editor.flushBuffer() - - - - - - \ No newline at end of file diff --git a/TestSkelette.py b/TestSkelette.py deleted file mode 100644 index c3e6817..0000000 --- a/TestSkelette.py +++ /dev/null @@ -1,26 +0,0 @@ -import numpy as np -from skimage.morphology import skeletonize -import matplotlib.pyplot as plt - -# Créer un tableau de booléens -image = np.ones((20, 20), dtype=bool) -image[1:-1, 1:-1] = True - -# Effectuer la squelettisation -skeleton = skeletonize(image) - -# Afficher les résultats -fig, axes = plt.subplots(nrows=1, ncols=2, figsize=(8, 4), sharex=True, sharey=True) - -ax = axes.ravel() - -ax[0].imshow(image, cmap=plt.cm.gray) -ax[0].axis('off') -ax[0].set_title('original', fontsize=20) - -ax[1].imshow(skeleton, cmap=plt.cm.gray) -ax[1].axis('off') -ax[1].set_title('skeleton', fontsize=20) - -fig.tight_layout() -plt.show() \ No newline at end of file diff --git a/grid_skeleton.png b/grid_skeleton.png deleted file mode 100644 index 0ed9da1e93fa5a873400431d9d62f8c73a60ae22..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 12944 zcmeHtcT|&Wx^Kja4Yv)YiXw=#jfiv*8=}&CSLq-`=@3G|js+A1r6Zzr0@6bXTZJgS z_omd)AtXQ`YCZHP@vJ7lE(5@B93oUwMMGG*owO=h%)yp?0ZV zzMz9bu>_z{8wR&+f$vB)^$x=qS@(-Z?z(7Ocdr|+HYoKQ?zeBD-ETSEJmP8N>gIrU zkra~=J0)_&-rfDSo1D0~^Iv~J4DD(seq?q13tWWt_GM!?6pHNz@^3?maD=zWOm$V4Z9Gwr)AR~tAK*DCq(XFKmY7U5OI#nT>B{PNJh~^`}89} z96W}6m0Ed^NF=mpU98xXqV=B3iM4sZ`C04NCj|Bso)CC^WdFv@?fbkQT>iAW`p9z3 zJ%%;G`qaG+%ANXEt}z0>cxIAt>W)RPo8bJLNLF~Z`o~Xco8W6>{gNIm-pilu;|NnzOu_SNa>J%f6j#v^{`$4Bu<%uVef_`!e+GRs zmE4wY*f^x0ZjhRia+$HZ#OA1}p|P918cwJC<`))DzEtJWHtT&YyF8}MEUpUXPPZZj z3n?j;OGa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FyQ!Qo}t=*}U zwm{_&tUEkEkA@!ibIMaH{pXZtX&Tp40^Oq}(^MMign;B7KoanG@3KI%i=oLKeVa=g zg(v`!>7{^X92d<{4H2Ku`PASrOgJ!^3OWQw%kq}QC5m9vQf@q>7E)q3h!(k{qoZfB z>nme{N{DeejW}m8wqgoI11?~sqN36$1BrAV_?TVOg##{NHe@6J2f~>FQ@c|>4fo?& zX41-xVJZZ1igIB-von}m{uY?{2ie)}z}lN>ruy%LH~+`FPRx8(x~XkI7op&>n3>{s z_;Y+xo*RA%;%Uhck`)9o2~e!YFe(a3O%;re-K#%vmEee82Y%E8qb<&WtME)`N`Q(W zd2zoVrS9it4`V2=iEEXRW8G>_Qd6;7n?~byEUpaRV-pb)`sP3X)Dn5zDHt^b(oN_B zXKM_8FLfdfE0J3w?9S<;Y1Z8xm)b9cK4C;m@Dy;FG;miufz_3z8#eRjr=p5FuQ>I-!iuPuLl)O a-h29f&)O49Z9vzd)GlgV$U1lZ?tcKQXGU!R diff --git a/list_block.py b/list_block.py deleted file mode 100644 index af99e90..0000000 --- a/list_block.py +++ /dev/null @@ -1,70 +0,0 @@ -from gdpc import Block - - -air = Block('air') - - - - - - - -style_basique={ - 'mur':"white_concrete", - 'sol':"oak_planks", - 'toit':"oak_planks", - 'grass':"grass_block", - 'chemin':"quartz_block", - 'fence':'oak_fence', - 'toit_esca':'oak_stairs', - 'toit_planche':"oak_planks", - 'toit_slab':'oak_slab', - 'glass':"glass", - 'door':'oak_door' - - - } - -style_jungle={ - 'mur':"light_gray_concrete", - 'sol':"acacia_planks", - 'grass':"grass_block", - 'chemin':"podzol", - 'fence':'acacia_fence', - 'toit_esca':'acacia_stairs', - 'toit_planche':"acacia_planks", - 'toit_slab':'acacia_slab', - 'glass':"glass", - 'door':'acacia_door' - - - } -style_end={ - 'mur':"purple_concrete", - 'sol':"crimson_planks", - 'grass':"grass_block", - 'chemin':"amethyst_block", - 'fence':'crimson_fence', - 'toit_esca':'crimson_stairs', - 'toit_planche':"crimson_planks", - 'toit_slab':'crimson_slab', - 'glass':"glass", - 'door':'crimson_door' - - - } - -style_birch={ - 'mur':"yellow_concrete", - 'sol':"birch_planks", - 'grass':"grass_block", - 'chemin':"rooted_dirt", - 'fence':'birch_fence', - 'toit_esca':'birch_stairs', - 'toit_planche':"birch_planks", - 'toit_slab':'birch_slab', - 'glass':"glass", - 'door':'birch_door' - - - } \ No newline at end of file diff --git a/temp.py b/temp.py deleted file mode 100644 index 448d83b..0000000 --- a/temp.py +++ /dev/null @@ -1,227 +0,0 @@ - for i in range(-1, width+1): - for j in range(-1, depth+1): - if width Date: Sat, 15 Jun 2024 17:20:28 +0200 Subject: [PATCH 18/18] adding negative co utilisation --- House.py | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/House.py b/House.py index 1452168..68f4bb7 100644 --- a/House.py +++ b/House.py @@ -10,7 +10,6 @@ class House: self.editor = editor self.coordinates_min = coordinates_min self.coordinates_max = coordinates_max - self.grid = np.zeros((coordinates_max[0], coordinates_max[2]), dtype=[('bool', bool), ('int', int)]) self.skeleton = [] size = [(coordinates_max[i] - coordinates_min[i]) + 10 for i in range(3)] @@ -73,12 +72,13 @@ class House: for i in range(0, width-1): for j in range(0, depth-1): self.editor.placeBlock((x + i, y_min, z + j), self.floor) - self.grid[x+i,z+j] = True,1 self.grid3d[x_plan3d+i,0,z_plan3d+j] = True,1 self.skeleton.append((x, z, width-1, depth-1, height)) print("Coordinates of the corners: ", (x, z), (x, z+depth-1), (x+width-1, z), (x+width-1, z+depth-1)) + + x_min -= 1 x_max -= 1 z_min += 1 @@ -95,23 +95,23 @@ class House: new_x = np.random.randint(max(x_min+1, x - new_width ), min(x_max-new_width - 1, x + width )) new_z = np.random.randint(max(z_min+1, z - new_depth), min(z_max-new_depth - 1, z + depth )) - + new_x_plan3d = new_x - x_min -1 + new_z_plan3d = new_z - z_min +1 adjacent_blocks = 0 - for i in range(new_x, new_x + new_width): - for j in range(new_z, new_z + new_depth): - if self.grid[i-1,j]['bool'] and self.grid[i-1,j]['int']==1 or self.grid[i+1,j]['bool'] and self.grid[i+1,j]['int']==1 or self.grid[i,j-1]['bool'] and self.grid[i,j-1]['int']==1 or self.grid[i,j+1]['bool'] and self.grid[i,j+1]['int']==1: + for i in range(new_x_plan3d, new_x_plan3d + new_width): + for j in range(new_z_plan3d, new_z_plan3d + new_depth): + if self.grid3d[i-1,0,j]['bool'] and self.grid3d[i-1,0,j]['int']==1 or self.grid3d[i+1,0,j]['bool'] and self.grid3d[i+1,0,j]['int']==1 or self.grid3d[i,0,j-1]['bool'] and self.grid3d[i,0,j-1]['int']==1 or self.grid3d[i,0,j+1]['bool'] and self.grid3d[i,0,j+1]['int']==1: adjacent_blocks += 1 if adjacent_blocks < 3: continue - if not np.any(self.grid[new_x:new_x+new_width, new_z:new_z+new_depth]['bool']): + if not np.any(self.grid3d[new_x_plan3d:new_x_plan3d+new_width,0, new_z_plan3d:new_z_plan3d+new_depth]['bool']): new_x_plan3d = new_x - x_min new_z_plan3d = new_z - z_min for i in range(0, new_width): for j in range(0, new_depth): - self.grid[new_x + i, new_z + j] = True,2 self.grid3d[new_x_plan3d + i,0, new_z_plan3d + j] = True,2 if i == 0 or i == new_width-1 or j == 0 or j == new_depth-1: @@ -147,10 +147,9 @@ class House: for j in range(-1, depth+1): for y in range(0, height): if i == -1 or i == width or j == -1 or j == depth: - if not (self.grid[x + i, z + j]['bool']) and not (self.grid[x + i, z + j]['int'] == 1) or (self.grid[x + i, z + j]['bool'] and self.grid[x + i, z + j]['int'] == 2): + if not (self.grid3d[x_plan3d + i,y, z_plan3d + j]['bool']) and not (self.grid3d[x_plan3d + i,y, z_plan3d + j]['int'] == 1) or (self.grid3d[x_plan3d + i,y, z_plan3d + j]['bool'] and self.grid3d[x_plan3d + i,y, z_plan3d + j]['int'] == 2) or y==0: self.editor.placeBlock((x + i, self.coordinates_min[1] + y, z + j), self.wall) self.grid3d[ x_plan3d+i, y, z_plan3d+j] = True - #print( i, y, j, self.grid[x + i, z + j]['bool'],self.grid[x + i, z + j]['int']) def getAdjacentWalls(self):