You are on page 1of 15

Boids: Modeling and Understanding

emergent behavior

Sudeep Pillai
sudeepp@umich.edu
Background

• Natural and often seen, yet so intriguing


o Discrete birds, but an overall fluidic motion
o Magnificent synchronized behaviors

• Each bird dependent on each other


o Based on local perception, they control themselves
o No awareness of global perspective
o Seems like a distributed control
o Is it intentional??
Intentional flocking

• Formations
o Classic “Flying V” formation
– Reduce overall drag force as compared to flying alone

– Upwash produces free lift allowing lower angle of attack


– Lead bird – Two flanking birds dissipate downwash
The “Flying V” formation

• Reduced Energy expenditure


o Greater number cause further reduction in induced drag
– Birds towards the middle gain considerable advantage
– Flanking birds gain free lift through upwash
– Reduced induced drag for birds being flanked
– Research – 70% more flight time, reduced heart rates
– Lead bird – Two flanking birds dissipate downwash

• Communication & Cooperation


o Mutual cooperation – Flock Rotations
 Evolved over time
 Efficient flying formation thereby increasing flight time
 Distribution of responsibility within flock during rotations
More reasons to flocking

• Protection from predators


o Statistically improved survival of gene pool from attacks
o Each creature has knowledge of its local perception
o Cry signals for predator warning increases reaction time

• Improved foraging
o Larger effective search patterns

• Advantages for social and mating activities


Emergent behavior

• Formation of efficient flying order


o Reduced Energy expenditure
o Effective communication among flock
o Improved knowledge and avoidance of predator
o Improved foraging
o Increased social and mating activities

• Emergence - Complex global behavior (flocking)


arising from simple local interaction
Modeling emergent behavior

• Do we model emergence in behavior or the


result of emergence (i.e. flocking) ?
o Relatively trivial (using current technology) to create a model
that simulates flocking (boids)
o Less trivial to model emergence and tracing the path towards
flocking

• Accomplishing
• the former leads us to understanding the latter
• the latter is difficult, and very specific
Modeling boids

• Basics
o Separation, Alignment, Cohesion

• Slight modifications (In decreasing order of precedence)


o Collision Avoidance – avoid collision with nearby flockmates
o Velocity Matching – match velocity with nearby flockmates
o Flock Centering – stay close to nearby flockmates

• Additional modifications
oTendency towards goal, Limiting flock speed, Bounding
workspace, Perching, Obstacle avoidance, Boid neighborhood
The Algorithm
Moving boids – flock_move()
PROCEDURE
move_all_boids_to_new_positions()
Vector v1, v2, v3
flock_init_positions() Main instance Boid b
FOR EACH BOID b
Structure b (boids) Flock_init_positions () v1 = rule1(b)
FOR EACH BOID b LOOP v2 = rule2(b)
b.position =25* [2*rand-1; 2*rand-1;2* rand-1]; flock_draw_boids() v3 = rule3(b)
b.velocity = [0;0;0]; flock_move() …..
…..
END END LOOP
…..
b.velocity = b.velocity + v1 + v2 + v3 + ….
b.position = b.position + b.velocity
END
END PROCEDURE

Rule 1 : Seperation
Rule 2: Velocity Matching Rule 3: Flock centering
PROCEDURE rule1(boid bJ)
PROCEDURE rule2(boid bJ) PROCEDURE rule3(boid bJ)
Vector c = 0;
Vector pvJ Vector pcJ
FOR EACH BOID b
FOR EACH BOID b FOR EACH BOID b
IF b != bJ THEN
IF b != bJ THEN IF b != bJ && |b.position - bj.position| < 8
IF |b.position - bJ.position| < 100 THEN
pvJ = pvJ + b.velocity THEN
c = c - (b.position - bJ.position)
END IF pcJ = pcJ + b.position
END IF
END END IF
END IF
pvJ = pvJ / N-1 END
END
RETURN (pvJ - bJ.velocity) / 8  v2 pcJ = pcJ / N-1
RETURN c  v1
END PROCEDURE RETURN (pcJ - bJ.position) / 100  v3
END PROCEDURE
END PROCEDURE
The Algorithm (2) – Further additions
Moving boids – flock_move()
Tendency towards goal – flock_tendency() PROCEDURE
move_all_boids_to_new_positions()
PROCEDURE tend_to_goal(Boid b) Vector v1, v2, v3
Vector goal Boid b
RETURN (goal - b.position) / 100  v4 FOR EACH BOID b
END PROCEDURE v1 = rule1(b)
v2 = rule2(b)
v3 = rule3(b)
Predator interaction …..
…..
Same procedure as tendency towards
…..
goal, except a negative effect. b.velocity = b.velocity + v1 + v2 + v3 + ….
b.position = b.position + b.velocity
Return –v (from tend_to_goal)  v6 END
END PROCEDURE

Workspace bound – flock bound() FLOCK LEARNING


PROCEDURE bound_position(Boid b) Fitness functions being iteratively
Integer Xmin, Xmax, Ymin…… manipulated based on behavior needs
Vector v FOR EACH BOID b Limiting Speed – flock_limitvel()
IF b.position.x < Xmin THEN v1 = c1*rule1(b) PROCEDURE limit_velocity(Boid b)
v.x = 10 Integer vlim
v2 = c2*rule2(b)
ELSE IF b.position.x > Xmax THEN Vector v
v.x = -10
v3 = c3*rule3(b)
IF norm(b.velocity) > vlim THEN
END IF …..
b.velocity = (b.velocity/|b.velocity|*vlim)
….. b.velocity = b.velocity + v1 + v2 + v3 + …. END IF
.... b.position = b.position + b.velocity END PROCEDURE
Return v  v5 END
END PROCEDURE
Other possibilities

• Anti-flocking
o Dispersion of flock due to predator
o Negating flock centering almost solves the problem

• Other behaviors
o Negating separation – Boids run into each other
o Negating velocity matching – Boids have semi-chaotic
oscillations

• Different permutations of different behaviors with different fitness


functions not necessarily modeling flocks realistically
Optimization

• Trial and error and manual tweaking of


parameters using GAs
o Flocks can be tuned to exhibit interesting behavior
o Practical application may be limited

• Particle Swarm Optimization (PSO)


o Shares evolutionary computation techniques such as GA
o Unlike GA, it has no evolution operators (crossover, mutation)
o Strategy
 Initialized with random group
 Closest bird to food leads the flock
 Solution to the optimization is a single bird, not a group
 Each bird‟s fitness is re-evaluated and optimized
Simulation
Future work

• Modeling from the perspective of the bird


o Model effects of other birds that are in its view (local)
o Model effects of aerodynamics (CFD)
o Does it support the “Flying V formation”?

• Implementing highway traffic based on


distributed behavior control
o Simple to implement
o Highly reliable
o Energy efficient
My thoughts

• Several models and techniques have been


developed
o Some based on the behavior of flocks
o Some based on optimizing a specific task

• Similar to how we think of evolution, have


flocks „emerged‟ completely?
o Flocking in groups can be beneficial, as is evident. Are we in a
transitional phase? Or will they „emerge‟ further to optimize
flocking behavior?
o Can we predict of any possible optimizations they may
possibly undertake?

You might also like