02.06.2013 Views

boid - GAMA

boid - GAMA

boid - GAMA

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Practice in GAML<br />

BOIDS & BOIDS+<br />

Alexis Drogoul - IRD - France<br />

Presentation of the model<br />

Design of the model<br />

Implementation in GAML<br />

Additional features


2<br />

BOIDS: Introduction<br />

• Introduced in 1987 by Craig Reynolds as a model of the flocking (or herding<br />

or schooling) behaviours observed with intelligent life-forms, especially birds.<br />

• http://www.red3d.com/cwr/<strong>boid</strong>s/<br />

• Used for film animations (like The Lion King, or The Lord of the Rings)<br />

• BOIDS comes from “bird”+“oid” (like android, for instance).


Flocks and Boids<br />

• A flock exhibits polarized (aligned), non-colliding, aggregate motion. Motion is<br />

fluid, random, synchronized and gives an impression of intention and control<br />

• Yet, biological evidence: the collective motion is the aggregate result of<br />

individual actions of birds and not the result of a central control<br />

• The idea of Reynods was to simulate flocks by modeling the behavior of<br />

birds : local perception of the world, local interactions with other birds<br />

• A <strong>boid</strong> is then a bird-like agent (and the flock a multi-agent system).


4<br />

Original Boids Model<br />

• Interactions between <strong>boid</strong>s take place within a local neighborhood of each<br />

<strong>boid</strong>.<br />

• Three basic steering (navigation) behaviors:<br />

◐ Separation<br />

◐ Alignment<br />

◐ Cohesion<br />

• Each steering behavior directs the <strong>boid</strong> in a desired direction.<br />

• The directions are then combined (averaged, with or without weight, or<br />

prioritized) by the “brain” of the <strong>boid</strong> to obtain the final direction of flight.


Flocking – Steering Behaviors (1)<br />

• Separation: <strong>boid</strong>s steer to avoid crowding local flockmates.<br />

◐ Collision avoidance.<br />

◐ Keeps <strong>boid</strong>s a realistic distance apart.


6<br />

Flocking – Steering Behaviors (2)<br />

• Alignment (or Velocity Matching): <strong>boid</strong>s attempt to match the velocity<br />

(direction, speed) of their neighbors.<br />

◐ Complements separation.<br />

◐ Causes <strong>boid</strong>s to move in the same general direction.


7<br />

Flocking – Steering Behaviors (3)<br />

• Cohesion: <strong>boid</strong>s steer to move towards the average position of local<br />

flockmates.<br />

◐ Causes <strong>boid</strong>s to keep together in a local flock.<br />

◐ Allows flocks to both merge and bifurcate.


8<br />

Implementing it in GAML<br />

• Boids are initially placed randomly<br />

◐ What init procedure ?<br />

• Boids are able to move and perceive their environment (2D)<br />

◐ What skills ?<br />

• Boids will chose their direction depending on their perception<br />

◐ Which perception ?<br />

• Boids apply the three previous rules to make their choice (see pseudo-code<br />

after)<br />

◐ Which reflexes/actions ?


9<br />

Pseudo-code<br />

• These rules can be written in pseudo-code like:<br />

BOID.PROCEDURE move()<br />

Vector v1, v2, v3<br />

percept = perception()<br />

v1 = cohesion(percept)<br />

v2 = separation(percept)<br />

v3 = alignment(percept)<br />

velocity =velocity +v1 +v2 +v3<br />

location = location +velocity<br />

END PROCEDURE<br />

BOID.PROCEDURE cohesion(percept)<br />

Vector mc<br />

FOR EACH Boid b in percept<br />

mc = mc + b.location<br />

END<br />

mc = mc / size(percept)<br />

RETURN (mc - location) / CF<br />

END PROCEDURE<br />

BOID.PROCEDURE alignment(percept)<br />

Vector pv<br />

FOR EACH Boid b in percept<br />

pv = pv + b.velocity<br />

END FOR<br />

pv = pv / size(percept)<br />

RETURN (pv - velocity) / AF<br />

END PROCEDURE<br />

BOID.PROCEDURE separation(percept)<br />

Vector c<br />

FOR EACH Boid b in percept<br />

IF |b.location-location| < SF<br />

c = c-(b.location-location)<br />

END FOR<br />

RETURN c<br />

END PROCEDURE


10<br />

BOIDS+<br />

1.Apply a boundary to prevent the birds from “escaping” the environment (or<br />

getting stuck on its borders). Same kind of rule as before:<br />

BOID.PROCEDURE bound()<br />

Vector V<br />

IF location.x < BF<br />

v = v + {BF,0}<br />

IF location.x > env_size.x - BF<br />

v = v - {BF,0}<br />

... Etc...<br />

RETURN V<br />

END PROCEDURE<br />

2.Add a goal that all birds will try to reach<br />

◐ The goal is a point randomly fixed by the world, changed everytime a bird is<br />

close to it<br />

BOID.PROCEDURE goal()<br />

RETURN (goal - location) / GF<br />

END PROCEDURE


11<br />

BOIDS+<br />

3.Apply a limit on the angle (AL) that a bird can turn each step<br />

◐ Idea: use the min and max properties of the heading variable<br />

4.Transform AF, BF, CF, GF, SF, and AL into global parameters<br />

◐ (and play with them!)<br />

5.Add a new species of agents: obstacles.<br />

◐ Placed at random, immobile, cannot be “crossed” by birds<br />

◐ Add the necessary rule in birds<br />

◐ The flocks should split and reform with certain parameter sets (like “real birds”)<br />

6.Make the obstacles move slowly towards birds<br />

• Add the necessary parameters to the world to control them

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!