i have made an array of a box and i want to run galapagos to find wich boxes to be on
as you can see i used the list item and have integers from 0 to 63
i want 16 DIFFERENT integers
can anyone help me?
It would be easy enough to pick 16 different integers out of a set bigger than 16 if you were allowed to use a random number sequence. However using random generally does not play nice with Galapagos since it introduces a large amount of discontinuity between the input (the random seed) and the output (the list of integers). Change the seed even slightly, and you get a completely different set of outputs.
A relatively easy solution (provided you know how) is to write a small script which inserts each integer into a list while making sure that there are no collisions. Various ways of handling collisions present themselves.
The attached file contains two C# script components for (a) generating a random list of integers without collisions and (b) removing collisions from an existing list of integers by incrementing each duplicate number until it stops being a duplicate.
There are loads of ways in which new numbers can be generated in case of collisions, this is merely a very simple one.
random_no_collision.gh (27.7 KB)
it works!thank you very much
i have another question
what if i always want at least one of the surfaces of each box to connect with another surface?so that it always produces a hole shape and not different smaller shapes
thank you in advance
I don’t know what “connect” means in this context. You’re going to have to upload some files and probably explain in more detail what you’re after.
So from a collection of cells that all have neighbouring cells, you want to pick a random collection of cells, while ensuring that the set as a whole is not disjoint?
That’s quite a complicated constraint and I have my doubts you can do it in vanilla Grasshopper because of all the conditionals and iteration involved. To make it even more difficult the slider values should retain a reasonable amount of continuity so that when you change an early slider the resulting set of cells doesn’t drastically change.
This sounds more like a topological/combinatorial problem than a geometric one. I have no idea how to do this without resorting to even more scripting, and quite a lot of non-trivial scripting at that.
Definitely sounds like something that can be approached using graph theory. Although, perhaps a simpler “hack” here might be to check that the resulting mesh isn’t disjoint, and if it is penalise the fitness value.