On some meshes, deep_copy() fails due to exceeding recursion depth.
Recreate
The below code generates a randomized mesh that produces the issue.
import random
from agents_playground.spatial.coordinate import Coordinate
landscape_size_width: int = 10
landscape_size_length: int = 10
tiles: list[Coordinate] = []
# Distribute the tile elevations
tile_elevations: list[int] = random.choices(
population=[0, 1, 2],
weights=[10,2,1],
k=landscape_size_width*landscape_size_length
)
tile_count = 0
for x in range(landscape_size_width):
for z in range(landscape_size_length):
tiles.append(Coordinate(x, tile_elevations[tile_count], z))
tile_count += 1
for t in tiles:
print(f'[{t[0]}, {t[1]}, {t[2]}, 3],')
Make a clone by building the second mesh from the Landscape data class.
Implement __deepcopy__() on the hierarchy of objects that need to be copied.
Replace the current HalfEdgeMesh implementation with one that uses index look ups over references. I think this is probably the right strategy, just in general for a better mesh implementation.
Situation
On some meshes, deep_copy() fails due to exceeding recursion depth.
Recreate
The below code generates a randomized mesh that produces the issue.
This produces: