I’ve got a basic random walk script. I’d like to modify it so that it turns inward, away from the boundary whenever it approaches it. Any ideas about how to approach this or suggestions for places to look are welcome! Thanks.

You need to add a vector to its movement inside the loop. The vector should point away from the boundary. You might find the closest point on the boundary to your walker, then evaluate the curve at that parameter to find the tangent. Then you can use a cross product with the tangent and z axis to find your ‘stay inside boundary’ vector. You’ll want to scale the magnitude of this s carefully. You could use an inverse square

Thank you @dharman! I integrated vectors into the script and then went in a slightly different direction. It works most of the time but it still sometimes jumps outside of the boundary - I’m trying to sort out why but it’s progress, I think.

Many thanks, @diff-arch. Very interesting context - this is exactly what I’m trying to do. If only I could script without Ghop components… future goals.

Well … never is toooooo late (or is it?). That said if you are in the AEC market sector go for C#.

Anyway for the general case (Lists of inner/outer GeometryBase containers either in 2 or 3 D) try to mastermind first some way to do this (Note: available RC RayShoot Method works on Breps (ignores Trims)/Meshes [not Curves] and requires some rethinking ASAP):

So if we “Loop Recursively” the above (with random generations , random amplitudes, random directions … etc etc PLUS using some sort of escape probability [a user controlled var]) we get that: