Title: Group Behaviors and Artificial Life
1Group Behaviors and Artificial Life
- Claire OShea
- COMP 259 Spring 2005
2Overview
- Motivation
- Flocks, Herds, and Schools
- Artificial Fishes
- Cognitive Modeling
- Constrained Animation of Flocks
- Summary
3Motivation
- Many animations require natural-looking behavior
from a large number of characters - Flock of birds
- School of fish
- Crowd of people
4Motivation
- How do we generate this motion?
- Keyframe every character
- This is very labor-intensive, usually ends up
looking unrealistic - OR...
- Let each character generate its own motion!
- Much easier, and produces natural, unscripted
motion
5Motivation
- Questions about this method
- How do we write rules to define natural behavior?
- Can self-directed characters do anything
intelligent? - How can we give the animator some control over
the scene? - Well find out in the papers
6Flocks, Herds, and Schools A Distributed
Behavioral Model
7Flocks, Herds, and Schools
- A flock is simply the result of the interaction
between the behaviors of individual birds. - Model a flock of boids (bird-oids) as a
particle system - Each particle has an orientation
- Behavior of one particle depends on other
particles
8Flocks, Herds, and Schools
- Modeling boid flight
- The boid itself can move only in one direction
(forward along its local positive z-axis) - The boid steers by rotating about its local x and
y axes - The boids local coordinate system can move and
rotate freely within world coordinates
9Flocks, Herds, and Schools
- Modeling boid flight
- Banking turns
- The y-axis is always aligned with the direction
of acceleration - During straight flight, this is gravity
- During a turn, radial forces cause the bird to
bank (rotate around its z-axis)
10Flocks, Herds, and Schools
- Modeling boid flight
- Gravity is used only to help define banking
angle it is not actually applied as a force - Upper bounds are set on speed and acceleration
- Other forces (buoyancy, drag) are not modeled
11Flocks, Herds, and Schools
- Modeling flocking behavior
- Three basic rules, each of which generates an
acceleration request - Collision Avoidance
- Avoid running into other boids or static
obstacles - Velocity Matching
- Match velocity with nearby flockmates
- Flock Centering
- Stay close to nearby flockmates
12Flocks, Herds, and Schools
- Combining acceleration requests
- Weighted average
- Fails in certain critical situations (ex.
imminent collisions) - Prioritized allocation
- Acceleration requests are accepted in priority
order, until the maximum acceleration is reached - Works well (at least for this simple system)
13Flocks, Herds, and Schools
- Simulated Perception
- All the behavior rules depend only on nearby
objects - An individual boid is only aware of other boids
which lie in a spherical region around it - Sensitivity falls off as the inverse square of
the distance
14 15Artificial Fishes Physics, Locomotion,
Perception, Behavior
- Xiaoyuan Tu and Demetri Terzopoulos, 1994
16Artificial Fishes
- Simulate a fish using a holistic model
- Physical form
- Movement
- Perception
- Behavior
17Artificial Fishes
- Fish Physics
- Spring-mass model
- 23 point masses, 91 springs
- External springs are muscles
- Fish moves by changing the rest length of these
springs!
18Artificial Fishes
- Fish Movement Swimming
- Fish swings its tail back and forth by
alternately contracting and relaxing the muscles
on each side - Displacement of water produces a reaction force
normal to the fishs body (Fiw) - r1, s2, r2, s2 amplitude and frequency of
muscle contractions - Control amount of force, and thus swimming speed
- Optimal values found experimentally
A reaction force (Fiw) is applied at point ni and
acts along the inward normal. It propels
the fish both sideways and forward.
19Artificial Fishes
- Fish Movement Turning
- Fish quickly contracts the muscles on one side
while relaxing them on the other - r0, s0, r1, s1 contraction amplitude and
frequency of the turning muscles - Experimentally determined for turns of 30, 45,
60, and 90 degrees - Arbitrary turns are generated by interpolating
these parameters
20Artificial Fishes
- More Fish Movement
- Pitch and yaw are controlled by the pectoral fins
- Force applied on the fins
- Raising or lowering the leading edge of the fin
makes the fish swim up or down - Setting the two fins at different angles causes
fish to roll - Setting fins perpendicular to body decreases
forward speed
fishs velocity
angle of fin to body
surface area
fins normal vector
21Artificial Fishes
- Fish Perception
- Simplified simulation of vision
- Fish can see things that are within its viewing
volume (a 300 degree solid angle around its head)
and not occluded - Radius of viewing volume determined by
translucency of the water
22Artificial Fishes
- Fish Behavior
- Fish behavior is influenced by several factors
- Individual habits (preset by animator)
- Mental state (functions evaluated at each
timestep) - Perceived environment
- Intention generator picks an intention based on
these factors.
23Artificial Fishes
- Fish Behavior
- Mental state
- Hunger
- Libido
- Fear
digestion rate
time since last meal
appetite
amount eaten
libido function
time since last mating
distance to predator i
fear of predator i
24Artificial Fishes
- Intention Generator
- Decides on a behavior based on mental state and
priority ordering - Check for imminent collisions
- Check for nearby predators (calculate F(t))
- Evaluate hunger and libido (H(t) and L(t))
- Evaluate happiness with the ambient conditions
25Artificial Fishes
A complete fish model
26Artificial Fishes
- Different types of fish can be created just by
changing the intention generator! - Predator Prey
27 28Cognitive Modeling Knowledge, Reasoning and
Planning for Intelligent Characters
- John Funge, Xiaoyuan Tu, and Demetri Terzopoulos,
1999
29Cognitive Modeling
- Builds on the idea of a holistic character model,
but adds another layer cognitive modeling - Character can learn about its environment
- Character can plan ahead to achieve goals
30Cognitive Modeling
- Some AI background situation calculus
- Situation a description of the state of the
world at a given time - Fluent a property of the world that can change
over time - Primitive action function that translates from
one situation to another situation - Precondition axiom a statement about the state
of the world before the primitive action - Effect axiom a statement about the state of the
world after the primitive action
31Cognitive Modeling
- Situation calculus examples
- (These examples are in CML, a language developed
for this paper) - Fluent
- Broken(x, s)
- Precondition axiom
- action drop(x) possible when Holding(x)
- Effect axiom
- occurrence drop(x) results in Broken(x)
Whether x is broken in situation s
A primitive action
32Cognitive Modeling
- Domain knowledge specification
- Character should not have perfect knowledge of
the world this is unrealistic and uninteresting. - A better model character makes plans based on
limited information, knows when it needs more
information - Need a way to express uncertainty about aspects
of the world!
33Cognitive Modeling
- Interval-valued Epistemic Fluents
- The usual way to represent uncertainty in AI is
with epistemic ?-fluents, but these are difficult
to implement. - An alternative is to use interval arithmetic!
- For each sensory fluent f, introduce an
interval-valued epistemic fluent If. - The width of the IVE fluent expresses uncertainty
about the value of f.
34Cognitive Modeling
- Interval-valued Epistemic Fluents Example
- speed(x, s) the speed of object x in situation
s - Ispeed(s) what the character thinks the speed
of x is in situation s - Suppose we know the speed at s0
- speed(x, s0) 20
- Ispeed(s0) lt20, 20gt
- As time goes on, we are less
- certain about the value!
- speed(x, s1) 25
- Ispeed(s1) lt10, 30gt
35Cognitive Modeling
- Character direction
- A character can plan by finding a sequence of
primitive actions that accomplish a goal - Equivalent to searching a tree
- Complexity exponential in the length of the
plan! - Animator can prune the search space by
specifying complex actions (sequences of
primitive actions) - Results in nondeterministic behavior the same
goal can be accomplished in many different ways!
36Cognitive Modeling
- Creating an animation with smart characters
- Still need all the lower-level modules (physics,
perception, behavior, etc) - Add a reasoning engine to choose a low-level
behavior! -
37Cognitive Modeling
- Example Prehistoric world
- A T-Rex wants to chase raptors out of its
territory - It knows that they will run away when it
approaches, so it herds them out
38Cognitive Modeling
- Example Undersea world
- A merman tries to escape from a shark
- The merman hides behind obstacles, so that the
shark cant see him
39Constrained Animation of Flocks
- Matt Anderson, Eric McDaniel, and Stephen
Chenney, 2003
40Constrained Animation of Flocks
- The papers we have looked at so far focus on
creating animations with minimal input from the
animator - But in real applications, the animator usually
wants to specify what happens in the scene!
41Constrained Animation of Flocks
- Two-step model for constrained animation
- Produce a trajectory that satisfies the
constraints - Evaluate plausibility and refine the trajectory
42Constrained Animation of Flocks
- Constraints
- Point constraints a character must be at a point
at a certain time - Center-of-mass constraints the center of mass of
some group must be at a point at a certain time - Shape constraints a group must lie inside a
polygonal shape - Except for point constraints, these are not
guaranteed to be satisfied only approximated.
43Constrained Animation of Flocks
- Behavior model
- Based on Reynolds model
- Each character gets a randomly sampled wander
impulse at each timestep. - The wander contribution added to the character is
a combination of this wander impulse and the
normalized wander contribution from the previous
timestep.
wci-1 previous wander contribution (normalized)
wii current wander impulse wci total wander
contribution for this timestep
44Constrained Animation of Flocks
- Finding initial trajectories
- Find configurations that satisfy all the
constraints, then interpolate trajectories in the
windows between them - Possible methods (some or all of these may be
used) - Forward simulation
- Path transformation
- Backward simulation
45Constrained Animation of Flocks
- Finding initial trajectories
- Forward simulation
- Used when initial conditions are given for a
window - Position characters to meet initial conditions,
then run an unconstrained simulation using the
behavior model
46Constrained Animation of Flocks
- Finding Initial Trajectories
- Path Transformation
- Used when the window is part of a sequence of
point or COM constraints - Fit a B-spline curve through the sequence of
points - Run a forward simulation, and at each timestep,
move the character onto the curve
47Constrained Animation of Flocks
- Finding Initial Trajectories
- Backward Simulation
- Used when end constraints are given for the
window - Position characters to meet end constraints, then
run the simulation backwards (just reverse the
birds perception) - Blend the resulting trajectory (xbackward) with
the forward simulation (xforward) using a
weighting function
48Constrained Animation of Flocks
- Evaluating plausibility of an animation
- Determine whether the wander impulses are
plausibly distributed (gw) - Determine how well the animation satisfies the
COM and shape constraints (gc, gs) - Bias the animation toward producing a single
flock (gf) - The overall plausibility function
49Constrained Animation of Flocks
- Evaluating the wander impulses
- From the given trajectories, we can deduce the
wander impulse of each character at each timestep - gw evaluates whether the wander impulses look
like they were sampled from the right
distribution - In this model, the wander impulses had uniformly
random direction and normally distributed length,
so we evaluate how well the lengths wii fit a
normal distribution
50Constrained Animation of Flocks
- Evaluating constraint enforcement
- Center of mass constraints
- COM(A, t) is the center of mass of the group at
time t - Cx is the center of mass defined in the
constraint - Shape constraints
- cs is a user-defined constant
- dist(S, A, t) calculates the sum-of-squares
distance of each character from the shape
51Constrained Animation of Flocks
- Generating a better animation
- If the current animation fails the plausibility
test, the system generates a new one using one of
the following strategies - Completely re-generate some or all of the
trajectories - Add random bumps to a trajectory
- Change the characters velocity along a
trajectory - Only point constraints are enforced during this
phase
52Constrained Animation of Flocks
- Repeat the sampling process for a given number of
iterations, or until a plausible animation is
found.
This animation was generated in 1000 iterations
(about two hours)
53- Demo Constrained Flocking
54Summary
- Flocks, Herds, and Schools
- Simulates boid physics, perception, and
behavior - Fairly unrealistic physics no attempt to
actually model flight - Fast and simple to implement, scales well to
large numbers of characters - No real control possible from animator
55Summary
- Artificial Fishes
- Simulates fish physics, perception, behavior, and
intentions - Realistic physics is used for movement (though
not always for rendering) - Intention generator enables fish to engage in
complex behaviors - No animator control possible, except in choosing
initial values
56Summary
- Cognitive Modeling
- Adds another layer of character simulation
(cognitive model) - IVE fluents create a realistic model of
characters domain knowledge - Tree searching lets character plan ahead to
accomplish a goal - Animator can help control scene by scripting a
series of actions
57Summary
- Constrained Animation of Flocks
- Introduces random variation into the trajectories
using a wander impulse - Allows animator to specify constraints on
movement - Not real-time requires an iterative refining
process - Produces plausible enough trajectories, not
always completely realistic ones
58Summary
- AI methods can generate complex animation of
multiple characters without low-level control
from the animator - Behavior rules can be combined with a
physically-based model to create realistic scenes - Problems
- Difficult to implement user-specified constraints
- Complexity issue hard to generate scenes with
many characters in real time