2D gravity packing of many randomly shaped closed polylines

I am trying to create a simulation using Kangaroo where I can fill a 2D box (towards one end, like gravity) with a bunch of randomly shaped polygons. I have been searching on here for a simple version of this that I could use but haven’t found one that matches what I’m looking for. Can someone point me to a relevant post, or let me know if there already is a simple example of this that I could play around with? Thanks

Thanks, but is there a faster way to do 2D curve collision? The method shown in this post works great for these 50 curves, but if I increase it to 200 it’s incredibly slow. I imagined that for 2D Rigid simulation, I could use a lot more curves and it would still be relatively fast.

Why don’t you upload an example with your curves?

Sure. There’s not much to it, but here is what I’m trying:
stack-test.gh (12.8 KB)

For polylines it can sometimes be better to use the line segments in the ‘Collider’ goal instead of CurveCollide

polycollide_segments.gh (25.4 KB)

The main difference is that this goal does some sorting first to avoid full intersection checks of all against all. I should probably add the same thing to the CurveCollide goal.