# Galapagos question

hello guys
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?
thank you

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)

1 Like

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

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.

i want always a closed brep.for example,i want something like this

or like this

but not like this

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.