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