Agent trails with perlin noise and attractors

Hello,

I need help with an agent-based simulation (stigmergy/swarm), where I am trying to combine a vector field (noise) with goal-based attractors in order to generate trajectories between predefined points, rather than chaotic dispersion and “web-like” patterns, which is what I am currently getting.

I have a working script that generates agent movement within a field. Inside a rectangular domain, a vector field is defined, and agents leave trails that are later converted into curves. The problem is that with the current logic, agents either escape the field boundaries or get stuck in local loops, forming “curls” and dense clusters, instead of building directed connections between points.
The target principle I am aiming for is the following:

  1. First, a vector field is defined together with several key points (nodes).
  2. Then, agents are spawned at starting points and are expected to move toward target points.
  3. The movement should not be linear: the goal is to generate smooth, organic trajectories, where noise acts locally (as a form of “liveliness” or variation in the path), while the overall motion consistently progresses toward the target.
  4. Finally, trails are converted into curves, forming a woven network or connective structure between the nodes.

I am likely mixing the forces incorrectly.
Noise is implemented as a constantly changing acceleration or offset, and as a result, simply adding it to the vector pointing toward the nearest attractor either does not work (the noise overrides the direction), or produces overly straight paths when the attraction force is strongly increased.

Note: my .gh file is based on examples from open educational materials (Università di Bologna / a3-Unibo). I slightly adapted — and partially “broke” — one of the tutorial examples to fit my use case. I will therefore reference the original source and attach the current version of my file.

Thank you in advance. I am attaching the .gh file and screenshots — any advice or ideas would be greatly appreciated :folded_hands:
Swarm_Attractors_test.gh (45.7 KB)

Maybe something like that?

Hello

for this kind of work I think you can use a good plugin for that, like Culebra

https://www.food4rhino.com/en/app/culebra

Or use some code in order to add more behavior to you agent. Following a Vector field is like rain on mountain it is more one way.

2 Likes