flocking and group behavior

41
Flocking and Group Behavior Luv Kohli COMP259 March 24, 2003

Upload: isabel

Post on 22-Jan-2016

68 views

Category:

Documents


0 download

DESCRIPTION

Flocking and Group Behavior. Luv Kohli COMP259 March 24, 2003. Outline. First, birdies! Craig Reynolds paper on flocking Then, fishies! Tu & Terzopoulos paper on artificial fishes. What is a flock?. One definition: a group of birds or mammals assembled or herded together. - PowerPoint PPT Presentation

TRANSCRIPT

Page 1: Flocking and Group Behavior

Flocking and Group Behavior

Luv KohliCOMP259

March 24, 2003

Page 2: Flocking and Group Behavior

Outline

• First, birdies!– Craig Reynolds paper on flocking

• Then, fishies!– Tu & Terzopoulos paper on artificial

fishes

Page 3: Flocking and Group Behavior

What is a flock?

• One definition: a group of birds or mammals assembled or herded together

Page 4: Flocking and Group Behavior

Why model flocking?

• It looks cool• Difficult to animate using traditional

keyframing or other techniques– Hard to script the path– Hard to handle motion constraints– Hard to edit motion

Page 5: Flocking and Group Behavior

Boids!

• “boids” comes from “bird-oids”• Similar to particle systems, but have

orientation• Have a geometric shape used for

rendering• Behavior-based motion

Page 6: Flocking and Group Behavior

Boid motion (1)

• Boids have a local coordinate system

Page 7: Flocking and Group Behavior

Boid motion (2)

• Flight is accomplished using a dynamic, incremental, and rigid geometrical transformation

• Flight path not specified in advance• Forward motion specified as

incremental translations in local +Z direction

Page 8: Flocking and Group Behavior

Boid motion (3)

• Rotation about X, Y, and Z axes for pitch, yaw, and roll

• No notion of lift or gravity (except for banking)

• Limits set for maximum speed and maximum acceleration

Page 9: Flocking and Group Behavior

Flocking motion

• Boids must coordinate with flockmates• Two main desires:

– Stay close to the flock– Avoid collisions with the flock

• Flocking seems to have evolved due to protection from predators, higher chances of finding food, mating, etc.

Page 10: Flocking and Group Behavior

Flocking – 3 Behaviors (1)

• Collision avoidance: avoid collisions with nearby flockmates

Page 11: Flocking and Group Behavior

Flocking – 3 Behaviors (2)

• Velocity matching: attempt to match velocity with nearby flockmates

Page 12: Flocking and Group Behavior

Flocking – 3 Behaviors (3)

• Flock centering: attempt to stay close to nearby flockmates

Page 13: Flocking and Group Behavior

Arbitrating behaviors

• Behavioral urges produce acceleration requests: normalized 3D vector with importance in [0,1]

• Priority acceleration allocation is used instead of averaging acceleration requests

• Acceleration requests are prioritized and the most important ones are used up to a maximum acceleration

Page 14: Flocking and Group Behavior

Simulated perception

• Unrealistic for each boid to have complete knowledge

• Flocking depends upon a localized view of the world

• Each boid has a spherical neighborhood of sensitivity, based upon a radius and an exponent: 1/rn

• Can be exaggerated in forward direction

Page 15: Flocking and Group Behavior

Scripted flocking

• More control is needed for animation (e.g., flocks should be near point A at time t0 and near point B at time t1)

• Flock has a migratory urge towards a global target

• Global target can be moving and can vary depending on boids or other factors

Page 16: Flocking and Group Behavior

Avoiding obstacles (1)

• Force field approach– Obstacles have a field of repulsion– Boids increasingly repulsed as they

approach obstacle• Drawbacks:

– Approaching a force in exactly the opposite direction

– Flying alongside a wall

Page 17: Flocking and Group Behavior

Avoiding obstacles (2)

• Steer-to-avoid approach– Boid only considers obstacles directly

in front of it– Finds silhouette edge of obstacle

closest to point of eventual impact– A vector is computed that will aim the

boid at a point one body length beyond the silhouette edge

Page 18: Flocking and Group Behavior

Avoiding obstacles (3)

Page 19: Flocking and Group Behavior

Algorithmic considerations

• Naïve algorithm is O(N2)• This can be significantly reduced:

– Localizing each boid’s perception– Parallelization– Spatial partitioning can be used to

achieve O(1)

Page 20: Flocking and Group Behavior

On to fish!

• Want to model schooling and other behaviors:– Eating– Avoiding predators– Mating

• Modeled with limited memory, perception of the world, behavior, and physics

Page 21: Flocking and Group Behavior

Overview

Page 22: Flocking and Group Behavior

Physics-based fish model (1)

• Dynamic fish model consisting of 23 nodal point masses and 91 springs

• Spring arrangement maintains structural stability while allowing flexibility

• 12 springs run the length of the body to serve as simple muscles

Page 23: Flocking and Group Behavior

Physics-based fish model (2)

Page 24: Flocking and Group Behavior

Mechanics (1)

• Each node has:

– mass mi

– Position xi(t) = [xi(t) yi(t) zi(t)]

– Velocity vi(t) = dxi/dt

– Acceleration ai(t) = d2xi/dt2

Page 25: Flocking and Group Behavior

Mechanics (2)

• Spring Sij connects node i to node j

– Spring constant cij

– Rest length lij– Deformation eij = ||rij|| - lij

•rij = xj(t) – xi(t)

– Exerts force fsij = cijeij(t)rij/||rij|| on

node i, and –fsij on node j

Page 26: Flocking and Group Behavior

Mechanics (3)

• Equations of motion specified by:mi(d2xi/dt2) + ρi(dxi/dt) – wi = fw

i

ρi = damping factor

wi(t) = sum of spring forces

fwi = external (hydrodynamic) forces

• Integrated using numerically stable implicit Euler method

Page 27: Flocking and Group Behavior

How to swim fish-style (1)

• Artificial fish moves by contracting muscles

• Forward motion achieved by swinging tail, which displaces water

• Displaced water produces a reaction force normal to the fish’s body and proportional to the displaced volume

Page 28: Flocking and Group Behavior

How to swim fish-style (2)• Instantaneous force proportional to ∫s(n·v)nds• s = surface• v = relative velocity between surface and fluid• n = unit outward normal function over surface• Approximated withf=min(0, -A(n·v)n), whereA is triangle area. (1/3)f isgiven to each triangle node

Page 29: Flocking and Group Behavior

How to swim fish-style (3)

• Tail swinging achieved by contracting swimming muscles on one side and relaxing on the other side periodically

• Turning achieved by contracting one side sharply, relaxing the other side, then slowly relaxing the contracted side

• Swimming uses back two muscle groups, turning uses front two muscle groups

Page 30: Flocking and Group Behavior

Motor controllers

• Artificial fish has three motor controllers– Swim-MC(speed)

•Converts speed into contraction amplitude and frequency

– Left-turn-MC(angle)– Right-turn-MC(angle)

•Converts angle into parameters for muscles

Page 31: Flocking and Group Behavior

Sensory perception (1)

• Vision sensor: vision is cyclopean• Covers 300 degree spherical angle

extending to some effective radius based on water translucency

• Vision sensor has access to geometry, material properties, and illumination information

• Image is averaged to determine overall light

Page 32: Flocking and Group Behavior

Sensory perception (2)

• Temperature sensor• Samples ambient water temperature at

center of fish’s body

Page 33: Flocking and Group Behavior

Mental state (1)

• Fish’s mental state specified by:– Hunger

•H(t) = min[1-ne(t)R(∆tH)/,1]•ne(t) = amount of food consumed

•R(x) = 1 – p0x, po = digestion rate

•∆tH = time since last meal = appetite

– p0 = 0.005 results in ravenous fish

Page 34: Flocking and Group Behavior

Mental state (2)

• Fish’s mental state specified by:– Libido

•L(t) = min[s(∆tL)(1-H(t)), 1]

•s(x) = p1x, p1 = libido constant

•H is hunger•∆tL = time since last mating

– p1 = 0.01 results in sexual mania

Page 35: Flocking and Group Behavior

Mental state (3)

• Fish’s mental state specified by:– Fear

•F(t) = min(sum(min[Do/di(t), 1]),1)

•Do = 100 (constant)

•di(t) = distance to visible predator i

Page 36: Flocking and Group Behavior

Intention generator

Page 37: Flocking and Group Behavior

Satisfying intentions

• Once an intention is selected, control is passed to a behavior routine

• Eight behaviors:– Avoiding-static-obstacle– Avoiding-fish– Eating-food– Mating– Leaving– Wandering– Escaping– Schooling

• Behaviors can also have subroutines that are called

Page 38: Flocking and Group Behavior

Schooling

Page 39: Flocking and Group Behavior

Different fish types

• Predators, prey, pacifists• Each type has different intentions which

lead to different behavioral patterns• Pacifists exhibit mating behavior based

upon criteria for being interested in potential mates

Page 40: Flocking and Group Behavior

Pacifists

• A male fish selects a mate as follows:– A female of the same species is

preferred to one of other species– Closer females are more attractive

than ones further away• A female fish selects a mate similarly

but shows preference to male fish size (stronger, more protective) rather than proximity

Page 41: Flocking and Group Behavior

References

• Reynolds, C. W., 1987. "Flocks, Herds, and Schools: A Distributed Behavioral Model." Computer Graphics, 21(4): 25-34.

• Tu, X. and Terzopoulos, D. "Artificial fishes: Physics, locomotion, perception, behavior." Proc. ACM SIGGRAPH '94 Conference.