Presentation is loading. Please wait.

Presentation is loading. Please wait.

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

Similar presentations


Presentation on theme: "Flocking and Group Behavior Luv Kohli COMP259 March 24, 2003."— Presentation transcript:

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

2 Outline First, birdies! –Craig Reynolds paper on flocking Then, fishies! –Tu & Terzopoulos paper on artificial fishes

3 What is a flock? One definition: a group of birds or mammals assembled or herded together

4 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

5 Boids! “boids” comes from “bird-oids” Similar to particle systems, but have orientation Have a geometric shape used for rendering Behavior-based motion

6 Boid motion (1) Boids have a local coordinate system

7 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

8 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

9 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.

10 Flocking – 3 Behaviors (1) Collision avoidance: avoid collisions with nearby flockmates

11 Flocking – 3 Behaviors (2) Velocity matching: attempt to match velocity with nearby flockmates

12 Flocking – 3 Behaviors (3) Flock centering: attempt to stay close to nearby flockmates

13 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

14 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/r n Can be exaggerated in forward direction

15 Scripted flocking More control is needed for animation (e.g., flocks should be near point A at time t 0 and near point B at time t 1 ) Flock has a migratory urge towards a global target Global target can be moving and can vary depending on boids or other factors

16 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

17 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

18 Avoiding obstacles (3)

19 Algorithmic considerations Naïve algorithm is O(N 2 ) This can be significantly reduced: –Localizing each boid’s perception –Parallelization –Spatial partitioning can be used to achieve O(1)

20 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

21 Overview

22 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

23 Physics-based fish model (2)

24 Mechanics (1) Each node has: –mass m i –Position x i (t) = [x i (t) y i (t) z i (t)] –Velocity v i (t) = dx i /dt –Acceleration a i (t) = d 2 x i /dt 2

25 Mechanics (2) Spring S ij connects node i to node j –Spring constant c ij –Rest length l ij –Deformation e ij = ||r ij || - l ij r ij = x j (t) – x i (t) –Exerts force f s ij = c ij e ij (t)r ij /||r ij || on node i, and –f s ij on node j

26 Mechanics (3) Equations of motion specified by: m i (d 2 x i /dt 2 ) + ρ i (dx i /dt) – w i = f w i ρi = damping factor w i (t) = sum of spring forces f w i = external (hydrodynamic) forces Integrated using numerically stable implicit Euler method

27 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

28 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 with f=min(0, -A(n·v)n), where A is triangle area. (1/3)f is given to each triangle node

29 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

30 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

31 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

32 Sensory perception (2) Temperature sensor Samples ambient water temperature at center of fish’s body

33 Mental state (1) Fish’s mental state specified by: –Hunger H(t) = min[1-n e (t)R(∆t H )/ ,1] n e (t) = amount of food consumed R(x) = 1 – p 0 x, p o = digestion rate ∆t H = time since last meal  = appetite –p 0 = 0.005 results in ravenous fish

34 Mental state (2) Fish’s mental state specified by: –Libido L(t) = min[s(∆t L )(1-H(t)), 1] s(x) = p 1 x, p 1 = libido constant H is hunger ∆t L = time since last mating –p 1 = 0.01 results in sexual mania

35 Mental state (3) Fish’s mental state specified by: –Fear F(t) = min(sum(min[D o /d i (t), 1]),1) D o = 100 (constant) d i (t) = distance to visible predator i

36 Intention generator

37 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

38 Schooling

39 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

40 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

41 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.


Download ppt "Flocking and Group Behavior Luv Kohli COMP259 March 24, 2003."

Similar presentations


Ads by Google