Yes. The array will be fully populated at the start and remain so at the end. The number of colours, number of cells per colour and location of home points will vary from one run to another (There will always be one home location per colour).
As my post said, I was looking to find out if there is any pre-existing code or plug-in that might help before starting to code. I didn’t particularly want to reinvent the wheel. Pasting a stub gh file that generates an array of rectangles is not going to help someone remember a useful plugin.
I wasn’t asking for anyone to write code, but on behalf of the others for whom you did so, thank you.
I don’t think there is a way to do this without custom code.
Using a bool array to store which cells have been visited, starting from the home locations and adding squares from the sides to the center in an iterative process.
I fear you are right, but I think it will need to be more complicated, with an ability for a set colour to be displaced from a cell because the adjacent colour has run out of room. And perhaps an optimiser to prefer rounded regions to long thin ones. My thoughts are heading towards implementing a state machine to run this rather than simple iteration. First step though will be to come up with robust algorithms. I foresee a lot of work.
Code is awful, not optimized, does not always work. But maybe a step in the right direction ?
The idea is to find the square that is furthest away from its home, and try to swap it with the nearest wrong tile from this home - checking it’s not the same color and that the result indeed gives overall a better distance.