Random selection of cells in a grid, how to adjust weight of each group

My goal with the following definition is to:

  1. Generate a grid
  2. Divide this grid into 10 groups - let’s imagine for this example that each of the groups represent a different colour - but not necessarily be divided equally.
  3. The selection of squares from within the grid needs to be done randomly, in order to achieve a random distribution of coloured squares.
  4. Adjust the weight of each group with some number sliders - i.e. if I want more or less blue squares, I want to be able to adjust this separately.

Points 1-3 I’ve been able to do, using the Dispatch tool to split the grid, but I don’t know how to adjust the weights. Any advice on how best to approach this?

Random tiling.gh (7.9 KB)

using only GH components (no scripting) I would approach it like this:


Random tiling_1.gh (21.3 KB)

the gene pool allows you to weight the different cell groups

consider that the A part of definition is sort of bad :slight_smile:
somehow when doubles are transformed into integers and some rounding happens, we need to find a culprit to make the final total number of cells to be = to the total number we have generated

in this case the culprit is item at index 0, that gets recalculated as (total number of cells) - (sum of all the other used cells)… there for sure will be smarter methods, this was the fastest shortcut I could think about

this slider allows you to shuffle the cells differently:

B is probably the only thing that matters: it outputs a tree with 10 branches, each branch containing the cells that belong to each different group

1 Like

Thank you for the quick and detailed response! Very helpful.

1 Like

Hi,

But how would I be able to bake this (dividing the branches) without the number tags or to a simple graphic, where I could connect the squares of the same group together?
Random tiling_1.gh (22.7 KB)

Just delete the text tag component, you won’t see the numbers then. @inno just used this to visualize the different groups.

To isolate the geometry from one of the data tree branches, use the Tree Branch component.

You can consider baking each group to a different layer. The Human plugin has some useful tools in this regard (Create Layer, Create Attributes, and Bake Geometry components)


Random tiling_1 edit.gh (16.9 KB)

1 Like