Download presentation
Presentation is loading. Please wait.
Published bySuzanna Rodgers Modified over 9 years ago
1
Kristen Gardner
2
Outline Swarm Intelligence Flocking Basic Steering Swarms Applications Animals Vehicles People
3
Swarm Intelligence What is it? Artificial intelligence that is based on collective behavior of decentralized, self organized systems Examples? Flocks of birds, schools of fish (Boids) Ant colony Bees
4
What is Flocking? An example of emergent behavior which resembles the motion of a flock of birds, school of fish, or swarm of insects First simulated on a computer in 1986 by Craig Reynolds’ program Boids Considered emergent because unexpected behavior may occur when flocks split up and reunite to avoid obstacles
5
How Does Flocking Work? The behavior of each Boid is individual, but conforms to a few, relatively simple, rules Separation Alignment Cohesion Other, more complex rules may also be added Obstacle avoidance Goal seeking
6
Basic Rules separation: steer to avoid crowding local flock mates alignment: steer towards the average heading of local flock mates cohesion: steer to move toward the average position of local flock mates
7
Field of View To keep things “realistic,” respond only to the actions of neighboring Boids Example Fancy Example
8
Algorithmic Complexity Basic un-optimized implementation is O(n 2 ) Each Boid must calculate its distance from each other Boid Basic optimized implementation is O(kn) Area the flock inhabits is divided into a grid with each Boid in a “bin” Each Boid only needs to check its position relative to Boids in its (or neighboring) bins
9
Using Steering Model mass (scalar) position (vector) velocity (vector) max_force (scalar) max_speed (scalar) orientation (N basis vectors) Euler Integration for animation steering_force = truncate (steering_direction, max_force) acceleration = steering_force / mass velocity = truncate (velocity + acceleration, max_speed) position = position + velocity
10
Steering Behaviors Seek and Flee Pursue and Evade Wander Arrival Wall Following Path Following Flow Field Following
11
Seek and Flee Go toward or away from a static target Seek: desired_velocity = normalize (position - target) * max_speed steering = desired_velocity – velocity Flee: Inverse of seek
12
Pursuit and Evasion Similar to Seek and Flee, but estimates the quarry’s position in the future Based on the distance to the quarry, estimate the number of time steps (the predictor interval T) until the Boid could reach the quarry Base T on the distance between objects: T=Dc Based on the quarry’s current velocity, position, and the calculated predictor interval, estimate the target Use seek or flee algorithm to determine steering
13
Wander Multiple ways Random steering force at each frame Easy to implement May cause “twitching” behavior Retain steering direction, but make small displacement Constrain steering to a sphere (or circle in 2D) in front of the Boid Size of sphere determines how quickly heading can change
14
Arrival Similar to seek, but slows when approaching target target_offset = target - position distance = length (target_offset) ramped_speed = max_speed * (distance / slowing_distance) clipped_speed = minimum (ramped_speed, max_speed) desired_velocity = (clipped_speed / distance) * target_offset steering = desired_velocity - velocity
15
Path Following Boid steers to follow a predetermined path Velocity-based prediction of future position Future position projected to nearest point on path If distance from path is more than path radius, steer toward path
16
Variation of Path Finding Wall Following Approach a wall and maintain a certain distance from it Generate a new goal position and steer toward it Containment Use future position to determine if Boid will remain inside area If not steer back toward the center of area
17
Flow Field Following Steer to align with flow vectors steering = flow_direction-velocity
18
Obstacle Avoidance Multiple approaches can be used Force Field model Steer-to-avoid
19
Types of Collisions Obstacles Stationary Incoming Outgoing Sideswiping Response Circumvention Queuing
20
Force Fields The equation: k i is a scaling constant d i is the distance from the agent to the obstacle e i controls the magnitude of acceleration based on distance k i and e i should be negative for avoidance, positive values can be used for attraction Advantages: Easy to model Disadvantages: Field is exactly opposite, so no turning away from straight on Too weak far away, so long term planning may be required
21
Steer-to-Avoid Algorithm: Calculates silhouette for each obstacle Tests collision with current heading If there will be a collision, the Boid will aim for a point one body length beyond the silhouette Advantages: Only affected by obstacles directly in front of it
22
Combined Behaviors Crowd Path Following path following and separation Leader Following Leader: wandering, seek random position Followers: arrival, separation, follow path set by leader Unaligned Collision Avoidance Containment, predictive obstacle avoidance Queuing Seek, avoid, separation,
23
And the result is… So, little circles running around are great, but really, what can flocking do? The Lion King
24
Simple Swarms An alternative to flocking Due to complexity, flocking calculations may be prohibitive in real-time applications Does not attempt to avoid collisions between swarm members Use with large number of small creatures Spiders, rats, etc.
25
Swarms Introducing the swarm Drop from the ceiling, “explode” from a container Each agent has a separate timer, set to a random value, so the agents enter the scene gradually Algorithm Small changes in movement and direction should keep the agents separate “Outer zone” Increment agent’s speed if it is less than the maximum (should vary from agent to agent) If the agent’s heading is not roughly in the right direction (within some tolerance), rotate back to the correct heading “Inner zone” Behavior varies, depending on the overall desired movement of the group
26
Modified swarm Can add simple collision tests, simple path following, and some other behaviors while still maintaining O(n) complexity Also can be modified for agents who fly or walk on walls
27
Applications Why do we care about any of this? Animals: flocks, schools, herds People: crowds Vehicles: traffic When to flock, when to swarm? Flocking Small to medium number of creatures Use when behavior of creatures is major focus of game play Pikmin Swarms Large groups (tens or hundreds of agents)
28
Animals Ambient Enhance the environment Give more life-like feel Not relevant to game play Secondary Limited amount of interaction with the player Part of game play, but not the focus Should behave intelligently, but also limited so as not to distract from goals Primary Are focus of the game and have direct relation to primary objectives
29
Understand Behavior - Groups Flocks Stay together Don’t crowd each other Follow the leader Switch leaders occasionally Individuals break away sometimes, but don’t go too far Schools Very similar, but tend to change directions more often High cohesion and alignment, low separation
30
Understand Behavior – Solitary Does not mean antisocial, just not governed by the behavior of others Examples – chipmunks, eagles, etc. Stay in a limited area Efforts mainly directed toward feeding May or may not be comfortable with human presence Maintain “safe” distance, but only depart if pursued Low alignment and low to moderate cohesion
31
Ambient animals Bugs - Example behavior for butterflies Don’t fly in straight line Don’t always flap their wings Don’t flap wings in full beat Attracted to flowers and bright colors Avoid moving objects Stay in limited area Easily governed by simple rules
32
Primary and Secondary Tend to follow a schedule throughout the day Frequent a fixed number of places Have more than one active sensing mechanism, some more keen than others Senses are affected by factors in the environment Avoid human contact, but may be dangerous when cornered Typically predictable, but should also demonstrate unexpected behavior occasionally Require more complex individual behavior than ambient animals
33
Traffic Must obey traffic rules Stop signs and signals, speed limits, drive on correct side of street Can be implemented with messages when the vehicle approaches specific objects Set precedence A stop sign or pedestrian is more important than maintaining a certain speed Intersections – ticket system In order to go through, must be in possession of ticket After passing through, vehicle relinquishes control of the ticket
34
People “Milling” Low max speed, planning for collision avoidance, small changes in heading, follow social/safety conventions (stay on sidewalk) Pedestrians on sidewalk, small groups standing around Organized behavior Pay more attention to other agents Queuing, military formations, “doing the wave,” waiting at cross-walks, etc. Traumatic behavior High maximum speed, large changes in heading, ignore conventions (running into traffic) Run away from the crazy person with a big gun
35
Rome: Total War Strategy game – both turn-based and real time Game engine Has the ability to render 30,000 units on a single battle field Used by Decisive Battles (History Channel) to recreate historical battles Battle of Cannae Rome: Total War
36
Summary Flocking Emergent behavior that imitates a flock, school, or herd Computationally expensive for large groups Swarms Use when flocking too expensive (hundreds of agents) Organic motion, but flock mates may collide Applications Video games, movies/TV, simulations Animals, vehicles, people Understand what you want to model before you model it
37
Questions or Comments?
Similar presentations
© 2024 SlidePlayer.com. Inc.
All rights reserved.