Professional Documents
Culture Documents
emergent behavior
Sudeep Pillai
sudeepp@umich.edu
Background
• Formations
o Classic “Flying V” formation
– Reduce overall drag force as compared to flying alone
• Improved foraging
o Larger effective search patterns
• Accomplishing
• the former leads us to understanding the latter
• the latter is difficult, and very specific
Modeling boids
• Basics
o Separation, Alignment, Cohesion
• 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
• 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