Trouble controlling the already occupied cells with Anemone

Hello, we’re currently working on a project that aims to settle on a given topography. And we’re facing some issues with that in Grasshopper. We started with a random box on a land which actually emerge in a grid with some distance from the ground (box supposed to has feet).

After the initial box we check its neighbours and take the distance to the topography in z-axis. Then we select the one with the minimum difference to the initial boxes distance to topography. We place 3 rectangles to the selected side and repeat this process with the last box. There is a diagram showing the process we are trying to achieve. We repeat process for 6 times, thus we use Anemone plug in, however even though we use member index to eliminate already occupied grids by their center points, it does not work.

Here is also our grasshopper code and diagram.

dads18.05.gh (84.2 KB)

Any help is appreciated. Thank you.

1 Like

I’ve rewritten your script using trees to cut down on the code. Rather than relying on deconstructing strings, I used a closest point to remove past locations so there is no repeat walkover of past directions preventing an infinite loop. If it would go over a previous point, I increase the difference by 1,000,000 making the path the least viable. Let me know if you have any questions about the code.
dads18.06.gh (51.9 KB)
image