I’m currently working on a GHPython script where I’ve successfully divided a list into sublists, each containing four elements. Now, I’m facing the challenge of replacing some of these sublists with other lists randomly, using different probabilities. For instance, I aim to replace the sublist [1, 0, 1, 1]
with [1, 1, 1, 1]
with a probability of 60%, [1, 2, 1, 1]
with a probability of 20%, and [1, 3, 1, 1]
with a probability of 20%.
Since GHPython doesn’t offer the random.choices()
function and random.choice()
doesn’t support specifying weights for selection, I’m seeking guidance on implementing this functionality without relying on external libraries like NumPy. Additionally, once I’ve successfully replaced these sublists, how can I structure the output as a data tree within Grasshopper, or at least ensure that the output doesn’t appear as a list of IronPython.Runtime.List
objects?@Mahdiyar