Algorithm to Detect and Replace Blocks in Grids

Hello everyone,

I’ve developed an algorithm in Grasshopper and Python for assembling 9x9 grids to create larger grid. These 9x9 grids are composed of three types of residential blocks: quadr, five-module, and three-module. When combined, these larger grids can result in situations where the central modules lack natural daylight, necessitating adjustments. These situations typically occur in the corners of the 9x9 grids.

I’m looking for guidance on creating an algorithm or code to detect potential block configurations within these grid(which is based on a list of 0s and 1s, where 0 represents a filled cell with blocks, and 1 represents an empty cell). I want to replace these configurations with the desired block, which eliminates one or two modules from the center.

Is there a way to achieve this, and if so, could someone provide insights or suggestions?

Thank you in advance for your assistance.


You need something “like” this: (a) 3D > 2D [or better Z Count =1] + (b) some different rules [as shown it follows a different rule combo]. But I’m far and away from base (just the anims found not any C# that does it [in any X/Y/Z “box size”]).

PS: The explode option just allows to see the modules (i.e. the basic module combos colored accordingly).


thanks for your response :pray:t2: