python now works, jl can leave

This commit is contained in:
=
2024-02-06 18:54:53 +01:00
parent 60bef312b5
commit ca34ab8ba3
9 changed files with 32 additions and 299 deletions

View File

@@ -3,23 +3,31 @@ from polycube_encoder import PolyCubeEncdoder
import json
def main(maxlength:int):
polycubes = set([PolyCube([(0, 0, 0)], [(0, 0, 0)])])
initial_cube = PolyCube([(0, 0, 0)], [(0, 0, 0)])
n_size = [0]*maxlength
todo = [PolyCube([(0, 0, 0)], [(0, 0, 0)])]
todo = [initial_cube]
polycubes = [initial_cube.oriented_offsets[0]]
n_size[0] = 1
while len(todo) != 0:
polycube = todo.pop()
children = polycube.generate_children(maxlength)
for child in children:
if child in polycubes:
continue
if child_exists_in(child, polycubes):
continue
todo.append(child)
polycubes.add(child)
polycubes.append(child.oriented_offsets[0])
n_size[len(child.cubes)-1] += 1
with open("out.json", "w") as f:
f.write(json.dumps(polycubes, cls=PolyCubeEncdoder))
with open("count.json", "w") as f:
f.write(json.dumps(n_size))
def child_exists_in(child: PolyCube, polycubes: list):
for orientation in child.oriented_offsets:
if orientation in polycubes:
return True
return False
if __name__ == "__main__":
main(4)
main(7)