Flocking and more.  NPC groups can move in cohesive groups not just independently ◦ Meadow of sheep grazing? ◦ Hunting flock of birds? ◦ Ants? Bees?

Slides:



Advertisements
Similar presentations
Vectors and Two-Dimensional Motion
Advertisements

Creative Computing. Comments on Assignments Everyone did very well Report writing needs more work Jumping scale Update first then draw.
Chasing, Evading, Intercepting, Pattern Movements
7.2. AI E NGINE AND S TEERING B EHAVIOUR I Design of an AI Engine and introduction to steering in game AI.
This terms course Last term we both worked on learning 2 things –Processing –The concepts of graphics etc. This term will focus more on the basic concepts.
Chapter 3: Motion in 2 or 3 Dimensions
November 12, 2013Computer Vision Lecture 12: Texture 1Signature Another popular method of representing shape is called the signature. In order to compute.
Chapter 10 - Additional Scenario Ideas Bruce Chittenden.
Rotational Motion Chapter Opener. Caption: You too can experience rapid rotation—if your stomach can take the high angular velocity and centripetal acceleration.
Steering Behaviors GAM 376 Robin Burke Winter 2008.
Better Group Behaviors in Complex Environments using Global Roadmaps O. Burchan Bayazit, Jyh-Ming Lien and Nancy M. Amato Presented by Mohammad Irfan Rafiq.
Flocks, Herds, and Schools: A Distributed Behavioral Model By: Craig Reynolds Presented by: Stephanie Grosvenor.
1 CO Games Development 2 Week 22 Flocking Gareth Bellaby.
OBJECT-ORIENTED THINKING CHAPTER Topics  The Object-Oriented Metaphor  Object-Oriented Flocks of Birds –Boids by Craig W. Reynolds  Modularity.
Behavioral Animation Procedural Animation Type?. Behavioral Animation Introduced by C. Reynolds (1987) Animating many things at one time –A group of the.
Rick Parent - CIS682 Flocking Geometric objects Many objects Simple motion - e.g., local rules, more physics, collision avoidance Consider other members.
Kristen Gardner. Outline Swarm Intelligence Flocking Basic Steering Swarms Applications Animals Vehicles People.
University of Texas at Austin CS 378 – Game Technology Don Fussell CS 378: Computer Game Technology Dynamic Path Planning, Flocking Spring 2012.
Flocking References: xxx.
Chapter 32 Magnetic Fields.
1Notes  Assignment 2 is out  Flocking references  Reynolds, “Flocks, Herds, and Schools…”, SIGGRAPH’87  Tu and Terzopoulos, “Artificial Fishes…”, SIGGRAPH’94.
John S Gero Agents – Agent Simulations AGENT-BASED SIMULATIONS.
Motion in Two Dimensions
Better Group Behaviors in Complex Environments using Global Roadmaps O. Burchan Bayazit, Jyh-Ming Lien and Nancy M. Amato Andreas Edlund.
Introduction What is this ? What is this ? This project is a part of a scientific research in machine learning, whose objective is to develop a system,
Chapter 3 Vectors in Physics.
Steering Behaviors For Autonomous Characters
Physics 106: Mechanics Lecture 05 Wenda Cao NJIT Physics Department.
Chapter 3: VECTORS 3-2 Vectors and Scalars 3-2 Vectors and Scalars
Crowd Simulations Guest Instructor - Stephen J. Guy.
Vectors and Two-Dimensional Motion
MOTION.
Sources of the Magnetic Field
Chapter 3 Vectors and Two-Dimensional Motion. Vector vs. Scalar Review All physical quantities encountered in this text will be either a scalar or a vector.
Flow Fields Hao Li and Howard Hamilton. Motivation for Flow Fields Multiple AI algorithms in a computer game can produce conflicting results. The AI must.
Unit 3 Vectors and Motion in Two Dimensions. What is a vector A vector is a graphical representation of a mathematical concept Every vector has 2 specific.
Chapter 3 Vectors and Two-Dimensional Motion. Vector Notation When handwritten, use an arrow: When handwritten, use an arrow: When printed, will be in.
Liang, Introduction to Java Programming, Eighth Edition, (c) 2011 Pearson Education, Inc. All rights reserved Event Driven Programming, The.
Math / Physics 101 GAM 376 Robin Burke Fall 2006.
Chapter 10 Rotation.
Rotational Motion 2 Coming around again to a theater near you.
Chapter 4 Motion in Two Dimensions. Kinematics in Two Dimensions Will study the vector nature of position, velocity and acceleration in greater detail.
Chapter 1 Introduction to Game AI April 11,
CLASS 10 SCENE GRAPHS BASIC ANIMATION CS770/870. A scene Graph A data structure to hold components of a scene Usually a Tree of a Directed Acyclic Graph.
Advanced Computer Graphics Rigid Body Simulation Spring 2002 Professor Brogan.
Artificial Intelligence in Game Design Complex Steering Behaviors and Combining Behaviors.
Chasing, Evading, Intercepting, Pattern Movements
Particle Swarm Optimization † Spencer Vogel † This presentation contains cheesy graphics and animations and they will be awesome.
REFERENCES: FLOCKING.
Chapter 9 – Additional Scenarios. Marbles Collision Detection The Marbles scenario does not use any of the built-in Greenfoot collision detection.
Torque on a Current Loop
Artificial Intelligence in Game Design Lecture 8: Complex Steering Behaviors and Combining Behaviors.
Forces on Current Carrying Wires in Magnetic Fields Chapter 19 Herriman High School - AP Physics 2.
Lecture Outline Chapter 3 Physics, 4 th Edition James S. Walker Copyright © 2010 Pearson Education, Inc.
CSCI 4310 Lecture 5: Steering Behaviors in Raven.
Part 2 Kinematics Chapter 3 Vectors and Two-Dimensional Motion.
11/13/03CS679 - Fall Copyright Univ. of Wisconsin Last Time A* Improvements Hierarchical planning Pre-Planning.
Vectors Chapter 2.  Scalars and vectors : A scalar quantity: is a quantity that has magnitude only. Mass, time, speed, distance, pressure, Temperature.
Flocking Geometric objects Many objects
Advanced & Group Steering
3.1 Two Dimensions in Motion and Vectors
CIS 488/588 Bruce R. Maxim UM-Dearborn
Steering Behaviors GAM 376 Robin Burke Fall 2006.
Navigation In Dynamic Environment
Representing Motion Chapter 2.
CIS 487/587 Bruce R. Maxim UM-Dearborn
CIS 488/588 Bruce R. Maxim UM-Dearborn
FLOSCAN: An Artificial Life Based Data Mining Algorithm
Hiroki Sayama NECSI Summer School 2008 Week 2: Complex Systems Modeling and Networks Agent-Based Models Hiroki Sayama
Presentation transcript:

Flocking and more

 NPC groups can move in cohesive groups not just independently ◦ Meadow of sheep grazing? ◦ Hunting flock of birds? ◦ Ants? Bees? Creatures?  Other types of computer controlled NPCs ◦ Humans, Orcs, Catapults? ◦ Squadrons of aircraft? ◦ Friendly soldier squads? ◦ Simulate crowds of people loitering?

 Coordinated group movement, the idea: ◦ To have the NPCs move with the illusion of having purpose and coordination  One of the earliest, most successful group behavior  Flocking ◦ “Flocks, Herds, and Schools: A Distributed Behavioral Model”, Craig Reynolds, SIGGRAPH 1987 ◦ Originally intended for birds, fish and other creatures, but it can be modified for other types of NPCs

 Term used by Craig Reynolds to refer to this simulated flocks  Leaderless flock – able to stick in a group  3 simple rules ◦ Cohesion ◦ Alignment ◦ Separation  Neighborhood: Defines the area where these rules will come to effect

 Have each unit steer towards the average position of its neighbors  Units are attracted to one another as long as they are within range

 Have each unit steer so as to align itself to the average heading of its neighbors.  Match direction of units around it that it can detect

 Have each unit steer to avoid hitting its neighbors.  Units are repelled by non-member units or obstacles. Repel effect is inversely prop. to distance from unit

 Flocking neighborhood creates a range that units can detect for other same-group units, other-group units

 Some implementations use two neighborhoods – one for detection of units, one for separation to avoid other units

 Typically, a visibility arc or field-of-view (FOV) is used to define the neighborhood  Is this practical?  To what extend is each unit aware of its neighbors?

 Each unit is aware of its local surroundings  Each unit does not necessarily know what the entire group is doing at any given time

 Visibility arc defined by 2 parameters – arc radius r and angle θ  How do these parameters affect flocking motion?

 Large radius? Small radius?  Wide FOV? Narrow FOV?

 Narrow FOV: Squadron of jets, Sneaking up behavior  Wide FOV: Group of birds, Military army

 Steering forces to be applied on the units  Treat each unit as a rigid body that is able to turn and apply net steering force accumulated from each flocking rule  2 important techniques when implementing flocking ◦ Tuning is required so that no single rule dominates ◦ Modulation of steering forces so that contribution is not constant for all units

 In each game loop ◦ Cycle thru all units in the flock to acquire data (direction, speed, etc.) from unit’s neighbors ◦ For each unit, update with net steering force from the three rules  Each unit must update its view of the world each game loop (cycle thru all units in the flock)  Refer to textbook for more details on the implementation code snippet

void DoUnitAI(int i) { int j; int N; // Number of neighbors Vector Pave; // Average position vector Vector Vave; // Average velocity vector Vector Fs; // Net steering force Vector Pfs; // Point of application of Fs Vector d, u, v, w; double m; // multiplier, +1 or -1 bool InView; bool DoFlock = WideView||LimitedView||NarrowView; int RadiusFactor;... }

 Calculate average position – vector sum of their respective positions divided by total number of neighbors  Determine direction to turn and angle to steer towards  Steering force effected = Direction multiplier * Max steering force * angle of steering / scale factor

 Normalize each unit’s velocity vector to get heading unit vectors  Calculate average heading of all units – sum of heading unit vectors divided by total number of neighbors  Effected steering force is calculated same way as cohesion

 Separation is enforced by steering away from any neighbor that is within view AND within prescribed minimum separation distance  Because this steering force is corrective, direction multiplier goes the opposite way  Effected steering force = Direction multiplier * Max steering force * (Unit length * separation factor) / separation distance

 Flocking would be much more realistic if units also avoid running into objects in the game world  To detect whether an obstacle is in the unit’s path ahead, imagine that each unit has “feelers” like those on insects!  Well, if one feeler is not enough, maybe you might need a few feelers?  Let’s see how a single “feeler” works…

 v : “feeler”  Calculate vector a  Project a onto v by dot product to obtain p  Subtract p from a to get vector b  Test conditions: 1.Magnitude (p) < Magnitude (v) 2.Magnitude(b) < Radius (r)  If both tests pass, corrective steering required, otherwise unit can continue on its current heading

 Corrective force can be calculated as inversely prop. to distance from unit to the center of obstacle or Magnitude (a)  Effected steering force = Direction multiplier * Max steering force * (Collision Visibility Factor * Unit length for Magnitude(v) / Magnitude(a) )

 This obstacle avoidance algo will not necessarily guarantee zero collisions between units and obstacles. What are some likely problems?  What we have seen so far only applies to circular obstacles. What about block (rectangular) obstacles or other free forms shapes?

 So far, flocking behaviors are leaderless  By combining classic flocking with leader- based AI, many new possibilities are available!  Flocks may have greater purpose if follow a leader  Question: How to designate leader? Should we “appoint” a unit as leader? Or should we let them sort out themselves who should be a leader?

 Let’s focus on this particular method  Advantage: Any unit can become a leader at any given time, flock will not be leaderless if leader gets destroyed or separated from flock  Once a leader is established, we can implement any number of rules to have the leader do something meaningful ◦ Execute pattern movement or patrolling ◦ Chase or evade or intercept something

 Can you figure out an algorithm to do this?

 A possible solution: ◦ Determine the number of units directly in front of or within view of current unit being processed (velocity directions are available for use) ◦ If no other units are directly in front of the unit, it becomes the leader. The rest follows flocking rules  Any more ideas?

 Follow the Leader AI adds an interesting dimension into flocking and group coordinated behavior  More than one leader (of different purposes) can also be implemented  You can also implement flocking behavior for player-friendly/assisting NPCs where the “leader” is simply the player