hello everyone, I am trying to generate shapes by randomly reducing a number of squares from a grid of squares.
However, my goal is to get only the cases in which the remaining squares are all connected by at least one vertex. Attached is a more explanatory photo.
Also if anyone knows of a way to calculate the number of possible combinations with these constraints.
I ask for your help because I have been trying for weeks but can’t find solutions (I am a beginner).
Also attached is the GH file.
Thank you for your help Random Shape.gh (21.7 KB)
I think you could join the srfs together, then just remove all the single srfs. I haven’t tested if the srfs that are diagonal to each other would join, which would then not work, but other than that seems like the simplest solution.
This is something that’s difficult to do with vanilla Grasshopper - meaning without scripting -, since ideally you’d have to keep track of each cells live neighbours to know which ones can still be randomly removed.
I can think of a few ways to do this. If it doesn’t have to be absolutely perfect, then what I proposed above is a good enough solution. There’s also Jacques’ solution which seems to work. Then you could also find intersections between the polyline edges. I’m sure there’s more than just these. And these are all just with vanilla components.