Taking a few cues from ant colonies, I've been playing with the construction of vector fields from agent based pheromone distribution. Instead of agents receiving distance based forces from neighbours directly, forces are derived from gradients in the pheromone field they leave behind. In other words, each agent 'sniffs' for a desired pheromone value within a scalar field and moves towards it. Because of the indirect nature of agent-to-agent interaction, simulating large populations becomes much less computationally expensive.
Below is an example of the interaction between two populations of 50,000 agents. One seeks out a target and contributes to the pheromone puddle (cyan) while the other gets in the way and tries to clean up the mess (magenta).
Lately, apart from not posting enough, I've been experimenting with automata based scalar fields. Hopefully they'll play into the development of environmental vector fields within the agent/physics class library when I get a bit more time. For now though, I've been tinkering with them in isolation. Here's a quick processing sketch of some of the more interesting results.
What's going on above is a diffusion driven bifurcation. From a random starting value between 0 and 1, each cell iteratively adds the average delta between itself and each of its neighbours. The two distinct regions are produced by dragging each value towards 0 or 1 depending on its relationship to a set bifurcation value, in this case 0.5. To visualize how values are being exchanged, the field is contoured, producing moire patterning in steep regions.
Recently, development of the class library has focused on optimizing interactions between large populations of particles. Typically each particle is forced to perform a distance check between itself and all other particles in the system. From there it collects forces which are generally some function of this distance. In this case, computation time is proportional to the square of the particle count making large populations really chug. Enter spatial binning.
When forces are only active within a finite range (ie. boids, packing etc.) checking every particle isn't really necessary. By breaking down the simulation space into 3 dimensional domains or "bins", particles can perform their search by only checking the bins that sit within a local influence. Generally the more local the search, the more effective the optimization, assuming the bin size isn't too small or too large. The video above has 10000 agents interacting at about 15 fps. Prior to binning, just under 1000 agents were running at about the same speed. Excelsior.
I've been getting some requests for wooly paths source code for the past few months so I decided to clean up an early version of it in VB.net and hand it over to the internet. Grab it here.
I've simplified it a bit in an effort to keep the code clear. Unfortunately, in doing so, it takes a bit of a speed hit since some optimizations regarding large particle populations were left out. Feel free to use it / tinker with the source code however you like. All I ask for in return is street cred.
To unpack it a bit, each stick is composed of 3 particles, one in the middle and two on either end. Two springs span from either end to the middle and a third spring spans from end to end to provide some bending resistance. The middle particles are all involved in medium range, medium strength separative forces (grey circles) and slightly longer range, low strength cohesive forces (invisible). At the same time the end particles are trying to converge through small range, high strength cohesive forces (magenta circles).
In an effort to organize my life, I've been building up a class library based on some of the more recent agent / physics based work. I'm mainly interested in making the different behaviors more modular to better handle a variety of them interacting within the same simulation.
The self organizing hexes above use multiple scales of agent based behavior for overall cohesion and vertex convergence while springs do their best to preserve the geometry.
For now the class library is more of a growing personal tool set. In its current state it's pretty cryptic. If there's general interest though, I wouldn't be opposed to making it available after some more time in the oven.
As a continuation of the previous post, heres an exploration of some self organized dual networks. Threads are now split into two opposing sets. Agents along threads of the same set still try to bundle while avoiding agents belonging to the other set simultaneously. As before the magnitude and range of these cohesive and separative forces are being tinkered with real time in the video below.
The resulting nets serve as a non uniform skeleton for some space partitioning studies where each thread set occupies it's own continuous volume. Here's a look at the implicit surface between thread sets as the iso value shifts from positive to negative.
I'd spent some time on Frei Otto's minimal path experiments earlier, but here's an update using a more locally defined agent based approach. Similar to the previous post, range and magnitude of forces (cohesion and thread tension) are adjustable real time in order to get at various degrees of path optimization. What's not shown in the video is what happens when another thread set and separative forces are introduced. Coming soon. (gasp)
Just an update on the previous post; each agent now measures a pressure value from the total magnitude of separative force at each iteration. For now the pressure value is just driving the colour gradient with white being high pressure.
Circle packing has always seemed like one of those problems best left to real life. Put some marbles in a bag and behold. Computationally things get a bit more complicated as we're forced to approximate the solution over discrete time steps. To avoid overlap in large populations of circles this usually involves extremely high short range separative forces, extremely low long range cohesive forces, and a small time step to avoid explosions.
Here I'm experimenting with an agent based packing system where forces become more local, between circles and immediate neighbours. Real time control of the range and influence of cohesive and separative forces make for some stable tightly packed results while keeping the time step reasonably high. An agent based approach also presents some opportunities for embedding other properties that update over time. In this case, the radii vary based on some external attractor relationships but I'm looking to have it also informed by a "pressure" value received at each time step. Alternatively I could go find some spongy marbles.