Friday, November 30, 2012

The Red Queen Hypothesis

"Well, in our country," said Alice, still panting a little, "you'd generally get to somewhere else — if you run very fast for a long time, as we've been doing."
"A slow sort of country!" said the Queen. "Now, here, you see, it takes all the running you can do, to keep in the same place. If you want to get somewhere else, you must run at least twice as fast as that!"

Wednesday, November 14, 2012


Another little simple function i've been using in some codes (thanks wolfram mathworld),especially to project agents, running 2D ,on a mesh face.You can use it to project vectors on any planes too,giving at least three points.You will need toxiclibs for this(i know there is a way to do the same thing with toxi rays).

    Vec3D projectOnTriangle3D(Vec3D r, Vec3D a,Vec3D b,Vec3D c) {
    float aa, bb, cc, dd;
    float x1 = a.x;
    float y1 = a.y;
    float z1 = a.z;
    float x2 = b.x;
    float y2 = b.y;
    float z2 = b.z;
    float x3 = c.x;
    float y3 = c.y;
    float z3 = c.z;
    aa = y1 * (z2 - z3) + y2 * (z3 - z1) + y3 * (z1 - z2);
    bb = z1 * (x2 - x3) + z2  *(x3 - x1) + z3  *(x1 - x2);
    cc = x1  *(y2 - y3) + x2 * (y3 - y1) + x3  *(y1 - y2);
    dd = -(x1  *(y2  *z3 - y3  *z2) + x2  *(y3  *z1 - y1 * z3) + x3 * (y1 * z2 - y2  *z1));
    float z = (-dd - aa * r.x - bb * r.y)/cc;
    Vec3D projVec = new Vec3D(r.x, r.y, z);
    return projVec;

Saturday, November 10, 2012


I have been working on a model of tripod (going on with my studies about agents and embodiment), directly inspired by robotic arms structure.Each tripod is composed by agents and springs.Each arm (like some models of robotic arm) is made up by struts and ties that gives the tripods its ability of self-sustaining. Each node of the arms is composed by agents that have different ability and functions.This combination gives the tripos the capacity of move , seek ,float, jump, stick together and self organize into larger assemblies. The variation of flocking parameters after clustering ,gives control on morphological and structural organization of the assemblies.I have to say that this model is very reminds me a lot some sci-fi movies about spiderbots invasion!!

TRIPODS INVASION!! from Paolo Alborghetti on Vimeo.

Thursday, October 25, 2012

Initialize vector onto mesh face

Here is a little function i wrote some time ago. If you want to initialize your agents onto a specific face of your mesh , this is what you're looking for mate!.You provide,as argument, aWEFace and it returns a vec3D (toxiclibs library needed).

Vec3D initInTriangle3D(WEFace f) {
  Vec3D r = new Vec3D();
  float a1 = random(1.0);
  float a2 = random(1.0);
  Vec3D v0 = f.a.copy();
  Vec3D v1 = f.b.copy().sub(v0);
  Vec3D v2 = f.c.copy().sub(v0);
  r = v1.copy().scaleSelf(a1).addSelf(v2.copy().scaleSelf(a2).scaleSelf(1-a1));
  Vec3D r1 = new Vec3D(r.x, r.y, r.z);
  return r1;

Grab the processing file here.
I have other functions and piece of code that i'll be posting (hope weekly).

Friday, October 19, 2012

More to come

If i have to be honest, this is a fake post (had to upload at least a pic..sorry guys).

Thursday, October 11, 2012

Body studies

These are some of the initial studies a i did,about agent and bodies.Trying to escape as far as possible form isosurfacing, i decided to extend my agent class with toxiclibs VerletParticle class.This allowed me to connect different agents with springs.Now..."this is a story of a lonley agent named Bob walking on his way.One day he finally met another bob and said"hey mate,take my hand and we will walk toghether fo evah!(true story!).

SpringAgentsChain from Paolo Alborghetti on Vimeo.

The logical next step was implement that logic on mesh,turning vertices into agents,edges into spring.Changing flocking paramenters you can guide the deformation of the mesh.Interesting morphologies emerge.

SpringMeshAgent from Paolo Alborghetti on Vimeo.

Monday, October 8, 2012

Stigmergy models

Some mounths ago i've been working on some models of stigmergy,just to get confidence with the tools(processing) and the systems i'd have been working with, for my thesis.
The first model is basically based on a common flocking algorithm,but every agent perform flocking towards tail points, and not towards other agents.Here the diffusion of pheromone (like what happen in nature,see ants and termites) is simulated by range of vision of every agents, and pheromone decay by tail length (longer the tail,higer the probability of an agent to follow the others).
I implemented toxi pointoctree (thanks Tommaso Casucci),for optimisation of tail point search (long tails means bigger array of points---->kill framerate) and because i was interested in working with huge population of agents.Here a short video of the model:

stigmergic fibrous systems from Paolo Alborghetti on Vimeo.

The second model was based on the idea of using a vector field.The outcome was really simple and computationally lightweight.It was not stigmergy,but a kind of model of percolation.Here Every agent reads its future location and writes his speed in the field.I have to say that it's funny when you're trying something and you end up with something completely different.Here a short video of the model:

percolation 2 from Paolo Alborghetti on Vimeo.

The third model i've been working with,and was the one i've been working on the most,is based on a semplified version of the model of jeff jones based on chemotaxis (for the simulation of slime molds behavior).You can find more information here:
This code is based on a  pheromone field (field of values).Every cicle each agent deposits pheromone (like little farts...we can call it  "farting agent" ) and reads pheromone value correspondent to his future location (smell other agents farts).For more information about the model i suggest to take a look at the link above(nothing about farting in Jones papers obviously!!).
I have to say that this model is amazing!It is really lightweight,you can work with huge population and tuning parameters you can obtain a wide range of patterns.
Here a short video of the model (10000 agents,two different populations fighting for space occupation,each one eating the other one pheromone):

stigmergic networks_2 populations from Paolo Alborghetti on Vimeo.