167
Graham Pentheny Independent Game Developer & AI Researcher Crowd Simulation through Steering Behaviors and Flow Fields Tuesday, March 26, 13

Crowd Simulation through Steering Behaviors and Flow Fieldstwvideo01.ubm-us.net/o1/vault/gdc2013/slides/... · Graham Pentheny Independent Game Developer & AI Researcher Crowd Simulation

  • Upload
    others

  • View
    0

  • Download
    0

Embed Size (px)

Citation preview

Page 1: Crowd Simulation through Steering Behaviors and Flow Fieldstwvideo01.ubm-us.net/o1/vault/gdc2013/slides/... · Graham Pentheny Independent Game Developer & AI Researcher Crowd Simulation

Graham PenthenyIndependent Game Developer & AI Researcher

Crowd Simulation through Steering Behaviors and Flow Fields

Tuesday, March 26, 13

Page 2: Crowd Simulation through Steering Behaviors and Flow Fieldstwvideo01.ubm-us.net/o1/vault/gdc2013/slides/... · Graham Pentheny Independent Game Developer & AI Researcher Crowd Simulation

Graham Pentheny

“Effective Crowd Simulation for Mobile Games”

Tuesday, March 26, 13

Page 3: Crowd Simulation through Steering Behaviors and Flow Fieldstwvideo01.ubm-us.net/o1/vault/gdc2013/slides/... · Graham Pentheny Independent Game Developer & AI Researcher Crowd Simulation

Steering

Galcon Fusion, Copyright © 2012 Phil Hassey.

StarCraft II: Heart of the Swarm, Copyright © 2013 Blizzard

Entertainment, Inc.

Tuesday, March 26, 13

Page 4: Crowd Simulation through Steering Behaviors and Flow Fieldstwvideo01.ubm-us.net/o1/vault/gdc2013/slides/... · Graham Pentheny Independent Game Developer & AI Researcher Crowd Simulation

Steering●Component system●Specialized Behaviors●Encapsulate separate concerns

●Arbitration Function●Combine behaviors intelligently

Tuesday, March 26, 13

Page 5: Crowd Simulation through Steering Behaviors and Flow Fieldstwvideo01.ubm-us.net/o1/vault/gdc2013/slides/... · Graham Pentheny Independent Game Developer & AI Researcher Crowd Simulation

Steering●Component system●Specialized Behaviors●Encapsulate separate concerns

●Arbitration Function●Combine behaviors intelligently

Tuesday, March 26, 13

Page 6: Crowd Simulation through Steering Behaviors and Flow Fieldstwvideo01.ubm-us.net/o1/vault/gdc2013/slides/... · Graham Pentheny Independent Game Developer & AI Researcher Crowd Simulation

Steering●Component system●Specialized Behaviors●Encapsulate separate concerns

●Arbitration Function●Combine behaviors intelligently

1

24

3

Tuesday, March 26, 13

Page 7: Crowd Simulation through Steering Behaviors and Flow Fieldstwvideo01.ubm-us.net/o1/vault/gdc2013/slides/... · Graham Pentheny Independent Game Developer & AI Researcher Crowd Simulation

Steering●Component system●Specialized Behaviors●Encapsulate separate concerns

●Arbitration Function●Combine behaviors intelligently

1

24

3

Tuesday, March 26, 13

Page 8: Crowd Simulation through Steering Behaviors and Flow Fieldstwvideo01.ubm-us.net/o1/vault/gdc2013/slides/... · Graham Pentheny Independent Game Developer & AI Researcher Crowd Simulation

Steering●Component system●Specialized Behaviors●Encapsulate separate concerns

●Arbitration Function●Combine behaviors intelligently

1

24

3

+ =

Tuesday, March 26, 13

Page 9: Crowd Simulation through Steering Behaviors and Flow Fieldstwvideo01.ubm-us.net/o1/vault/gdc2013/slides/... · Graham Pentheny Independent Game Developer & AI Researcher Crowd Simulation

Steering●Component system●Specialized Behaviors●Encapsulate separate concerns

●Arbitration Function●Combine behaviors intelligently

1

24

3

+ =

Tuesday, March 26, 13

Page 10: Crowd Simulation through Steering Behaviors and Flow Fieldstwvideo01.ubm-us.net/o1/vault/gdc2013/slides/... · Graham Pentheny Independent Game Developer & AI Researcher Crowd Simulation

Steering

Tuesday, March 26, 13

Page 11: Crowd Simulation through Steering Behaviors and Flow Fieldstwvideo01.ubm-us.net/o1/vault/gdc2013/slides/... · Graham Pentheny Independent Game Developer & AI Researcher Crowd Simulation

SteeringSteering System Physics

Tuesday, March 26, 13

Page 12: Crowd Simulation through Steering Behaviors and Flow Fieldstwvideo01.ubm-us.net/o1/vault/gdc2013/slides/... · Graham Pentheny Independent Game Developer & AI Researcher Crowd Simulation

SteeringSteering System

Controller Input

Smoothing & Filtering A.D.L.

Physics

Tuesday, March 26, 13

Page 13: Crowd Simulation through Steering Behaviors and Flow Fieldstwvideo01.ubm-us.net/o1/vault/gdc2013/slides/... · Graham Pentheny Independent Game Developer & AI Researcher Crowd Simulation

SteeringSteering System

Controller Input

Smoothing & Filtering A.D.L.

Physics

Tuesday, March 26, 13

Page 14: Crowd Simulation through Steering Behaviors and Flow Fieldstwvideo01.ubm-us.net/o1/vault/gdc2013/slides/... · Graham Pentheny Independent Game Developer & AI Researcher Crowd Simulation

Traditional Crowd Simulation●1 path per agent●Redundant path calculations●Waypoint-fighting●local collision avoidance●RVO/movement planning●expensive at scale

●Cellular automata●lacks fluidity of motion

Tuesday, March 26, 13

Page 15: Crowd Simulation through Steering Behaviors and Flow Fieldstwvideo01.ubm-us.net/o1/vault/gdc2013/slides/... · Graham Pentheny Independent Game Developer & AI Researcher Crowd Simulation

Path Following

Tuesday, March 26, 13

Page 16: Crowd Simulation through Steering Behaviors and Flow Fieldstwvideo01.ubm-us.net/o1/vault/gdc2013/slides/... · Graham Pentheny Independent Game Developer & AI Researcher Crowd Simulation

Path Following

Tuesday, March 26, 13

Page 17: Crowd Simulation through Steering Behaviors and Flow Fieldstwvideo01.ubm-us.net/o1/vault/gdc2013/slides/... · Graham Pentheny Independent Game Developer & AI Researcher Crowd Simulation

Path FollowingObstacle

Tuesday, March 26, 13

Page 18: Crowd Simulation through Steering Behaviors and Flow Fieldstwvideo01.ubm-us.net/o1/vault/gdc2013/slides/... · Graham Pentheny Independent Game Developer & AI Researcher Crowd Simulation

Path FollowingObstacle

Tuesday, March 26, 13

Page 19: Crowd Simulation through Steering Behaviors and Flow Fieldstwvideo01.ubm-us.net/o1/vault/gdc2013/slides/... · Graham Pentheny Independent Game Developer & AI Researcher Crowd Simulation

Path FollowingObstacle

Tuesday, March 26, 13

Page 20: Crowd Simulation through Steering Behaviors and Flow Fieldstwvideo01.ubm-us.net/o1/vault/gdc2013/slides/... · Graham Pentheny Independent Game Developer & AI Researcher Crowd Simulation

Path FollowingObstacle

Tuesday, March 26, 13

Page 21: Crowd Simulation through Steering Behaviors and Flow Fieldstwvideo01.ubm-us.net/o1/vault/gdc2013/slides/... · Graham Pentheny Independent Game Developer & AI Researcher Crowd Simulation

Path FollowingObstacle

Tuesday, March 26, 13

Page 22: Crowd Simulation through Steering Behaviors and Flow Fieldstwvideo01.ubm-us.net/o1/vault/gdc2013/slides/... · Graham Pentheny Independent Game Developer & AI Researcher Crowd Simulation

Path FollowingObstacle

Artificial Choke Point!

Tuesday, March 26, 13

Page 23: Crowd Simulation through Steering Behaviors and Flow Fieldstwvideo01.ubm-us.net/o1/vault/gdc2013/slides/... · Graham Pentheny Independent Game Developer & AI Researcher Crowd Simulation

Flow Fields●Discrete approximation of a ‘flow function’●Best path from every cell to closest goal●Agents lookup path direction in flow field

Tuesday, March 26, 13

Page 24: Crowd Simulation through Steering Behaviors and Flow Fieldstwvideo01.ubm-us.net/o1/vault/gdc2013/slides/... · Graham Pentheny Independent Game Developer & AI Researcher Crowd Simulation

Flow Field GenerationopenList.addAll(  grid.goalCells  );while  (  !openList.isEmpty()  )  {        Cell  c  =  openList.pop();

       for  (  Cell  n  :  c.neighbors  )  {                float  alt  =  c.dist  +  distance(  n,  c  );                if  (  alt  <  n.dist  )  {                        n.dist  =  alt;                        n.flow  =  norm(  c.pos  -­‐  n.pos  );                }        }}

Tuesday, March 26, 13

Page 25: Crowd Simulation through Steering Behaviors and Flow Fieldstwvideo01.ubm-us.net/o1/vault/gdc2013/slides/... · Graham Pentheny Independent Game Developer & AI Researcher Crowd Simulation

Flow Field GenerationopenList.addAll(  grid.goalCells  );while  (  !openList.isEmpty()  )  {        Cell  c  =  openList.pop();

       for  (  Cell  n  :  c.neighbors  )  {                float  alt  =  c.dist  +  distance(  n,  c  );                if  (  alt  <  n.dist  )  {                        n.dist  =  alt;                        n.flow  =  norm(  c.pos  -­‐  n.pos  );                }        }}

Tuesday, March 26, 13

Page 26: Crowd Simulation through Steering Behaviors and Flow Fieldstwvideo01.ubm-us.net/o1/vault/gdc2013/slides/... · Graham Pentheny Independent Game Developer & AI Researcher Crowd Simulation

Agents

Tuesday, March 26, 13

Page 27: Crowd Simulation through Steering Behaviors and Flow Fieldstwvideo01.ubm-us.net/o1/vault/gdc2013/slides/... · Graham Pentheny Independent Game Developer & AI Researcher Crowd Simulation

Agents●Point mass●Collision Circle●Max Force●Max Speed●Neighbor Radius

Tuesday, March 26, 13

Page 28: Crowd Simulation through Steering Behaviors and Flow Fieldstwvideo01.ubm-us.net/o1/vault/gdc2013/slides/... · Graham Pentheny Independent Game Developer & AI Researcher Crowd Simulation

Agents●Point mass●Collision Circle●Max Force●Max Speed●Neighbor Radius

●Behaviors●Flow field following●Separation●Alignment●Cohesion

Tuesday, March 26, 13

Page 29: Crowd Simulation through Steering Behaviors and Flow Fieldstwvideo01.ubm-us.net/o1/vault/gdc2013/slides/... · Graham Pentheny Independent Game Developer & AI Researcher Crowd Simulation

Flow field followingvec2  FlowFieldFollow(Agent  agent,  Grid  grid)  {    vec2  desired  =  grid.flowAtPoint(agent.position);

   desired  =  desired  *  agent.maxSpeed;    desired  -­‐=  agent.velocity;

   return  desired  *  agent.maxForce  /  agent.maxSpeed;}

Tuesday, March 26, 13

Page 30: Crowd Simulation through Steering Behaviors and Flow Fieldstwvideo01.ubm-us.net/o1/vault/gdc2013/slides/... · Graham Pentheny Independent Game Developer & AI Researcher Crowd Simulation

Flow field followingvec2  FlowFieldFollow(Agent  agent,  Grid  grid)  {    vec2  desired  =  grid.flowAtPoint(agent.position);

   desired  =  desired  *  agent.maxSpeed;    desired  -­‐=  agent.velocity;

   return  desired  *  agent.maxForce  /  agent.maxSpeed;}

Tuesday, March 26, 13

Page 31: Crowd Simulation through Steering Behaviors and Flow Fieldstwvideo01.ubm-us.net/o1/vault/gdc2013/slides/... · Graham Pentheny Independent Game Developer & AI Researcher Crowd Simulation

Flow field followingvec2  FlowFieldFollow(Agent  agent,  Grid  grid)  {    vec2  desired  =  grid.flowAtPoint(agent.position);

   desired  =  desired  *  agent.maxSpeed;    desired  -­‐=  agent.velocity;

   return  desired  *  agent.maxForce  /  agent.maxSpeed;}

Tuesday, March 26, 13

Page 32: Crowd Simulation through Steering Behaviors and Flow Fieldstwvideo01.ubm-us.net/o1/vault/gdc2013/slides/... · Graham Pentheny Independent Game Developer & AI Researcher Crowd Simulation

Flocking●Move as a group●Separation + Cohesion●Clustering●Alignment●Face common direction

Tuesday, March 26, 13

Page 33: Crowd Simulation through Steering Behaviors and Flow Fieldstwvideo01.ubm-us.net/o1/vault/gdc2013/slides/... · Graham Pentheny Independent Game Developer & AI Researcher Crowd Simulation

Flocking●Move as a group●Separation + Cohesion●Clustering●Alignment●Face common direction

Tuesday, March 26, 13

Page 34: Crowd Simulation through Steering Behaviors and Flow Fieldstwvideo01.ubm-us.net/o1/vault/gdc2013/slides/... · Graham Pentheny Independent Game Developer & AI Researcher Crowd Simulation

Separation

Tuesday, March 26, 13

Page 35: Crowd Simulation through Steering Behaviors and Flow Fieldstwvideo01.ubm-us.net/o1/vault/gdc2013/slides/... · Graham Pentheny Independent Game Developer & AI Researcher Crowd Simulation

vec2  Separation(Agent  agent,  List<Agent>  neighbors)  {    if  (neighbors.empty())  return  vec2.zero;

   vec2  totalForce  =  vec2.zero;    for  (Agent  neighbor  :  neighbors)  {          vec2  pushForce  =  (agent.pos  -­‐  neighbor.pos)          totalForce  +=  1-­‐  (pushForce  /  agent.neighborRadius);    }        totalForce  /=  neighbors.count();    totalForce  *=  agent.maxForce;}

Tuesday, March 26, 13

Page 36: Crowd Simulation through Steering Behaviors and Flow Fieldstwvideo01.ubm-us.net/o1/vault/gdc2013/slides/... · Graham Pentheny Independent Game Developer & AI Researcher Crowd Simulation

vec2  Separation(Agent  agent,  List<Agent>  neighbors)  {    if  (neighbors.empty())  return  vec2.zero;

   vec2  totalForce  =  vec2.zero;    for  (Agent  neighbor  :  neighbors)  {          vec2  pushForce  =  (agent.pos  -­‐  neighbor.pos)          totalForce  +=  1-­‐  (pushForce  /  agent.neighborRadius);    }        totalForce  /=  neighbors.count();    totalForce  *=  agent.maxForce;}

Tuesday, March 26, 13

Page 37: Crowd Simulation through Steering Behaviors and Flow Fieldstwvideo01.ubm-us.net/o1/vault/gdc2013/slides/... · Graham Pentheny Independent Game Developer & AI Researcher Crowd Simulation

vec2  Separation(Agent  agent,  List<Agent>  neighbors)  {    if  (neighbors.empty())  return  vec2.zero;

   vec2  totalForce  =  vec2.zero;    for  (Agent  neighbor  :  neighbors)  {          vec2  pushForce  =  (agent.pos  -­‐  neighbor.pos)          totalForce  +=  1-­‐  (pushForce  /  agent.neighborRadius);    }        totalForce  /=  neighbors.count();    totalForce  *=  agent.maxForce;}

Tuesday, March 26, 13

Page 38: Crowd Simulation through Steering Behaviors and Flow Fieldstwvideo01.ubm-us.net/o1/vault/gdc2013/slides/... · Graham Pentheny Independent Game Developer & AI Researcher Crowd Simulation

Cohesion

Tuesday, March 26, 13

Page 39: Crowd Simulation through Steering Behaviors and Flow Fieldstwvideo01.ubm-us.net/o1/vault/gdc2013/slides/... · Graham Pentheny Independent Game Developer & AI Researcher Crowd Simulation

vec2  Cohesion(Agent  agent,  List<Agent>  neighbors)  {    if  (neighbors.empty())  return  vec2.zero;

   vec2  centerOfMass  =  agent.position;    for  (Agent  neighbor  :  neighbors)          centerOfMass  +=  neighbor.position;    centerOfMass  /=  neighbors.count();

   vec2  desired  =  centerOfMass  -­‐  agent.position;    desired  *=  agent.maxSpeed  /  desired.mag();

   vec2  force  =  desired  -­‐  agent.velocity;    return  force  *  (agent.maxForce  /  agent.maxSpeed);}

Tuesday, March 26, 13

Page 40: Crowd Simulation through Steering Behaviors and Flow Fieldstwvideo01.ubm-us.net/o1/vault/gdc2013/slides/... · Graham Pentheny Independent Game Developer & AI Researcher Crowd Simulation

vec2  Cohesion(Agent  agent,  List<Agent>  neighbors)  {    if  (neighbors.empty())  return  vec2.zero;

   vec2  centerOfMass  =  agent.position;    for  (Agent  neighbor  :  neighbors)          centerOfMass  +=  neighbor.position;    centerOfMass  /=  neighbors.count();

   vec2  desired  =  centerOfMass  -­‐  agent.position;    desired  *=  agent.maxSpeed  /  desired.mag();

   vec2  force  =  desired  -­‐  agent.velocity;    return  force  *  (agent.maxForce  /  agent.maxSpeed);}

Tuesday, March 26, 13

Page 41: Crowd Simulation through Steering Behaviors and Flow Fieldstwvideo01.ubm-us.net/o1/vault/gdc2013/slides/... · Graham Pentheny Independent Game Developer & AI Researcher Crowd Simulation

vec2  Cohesion(Agent  agent,  List<Agent>  neighbors)  {    if  (neighbors.empty())  return  vec2.zero;

   vec2  centerOfMass  =  agent.position;    for  (Agent  neighbor  :  neighbors)          centerOfMass  +=  neighbor.position;    centerOfMass  /=  neighbors.count();

   vec2  desired  =  centerOfMass  -­‐  agent.position;    desired  *=  agent.maxSpeed  /  desired.mag();

   vec2  force  =  desired  -­‐  agent.velocity;    return  force  *  (agent.maxForce  /  agent.maxSpeed);}

Tuesday, March 26, 13

Page 42: Crowd Simulation through Steering Behaviors and Flow Fieldstwvideo01.ubm-us.net/o1/vault/gdc2013/slides/... · Graham Pentheny Independent Game Developer & AI Researcher Crowd Simulation

vec2  Cohesion(Agent  agent,  List<Agent>  neighbors)  {    if  (neighbors.empty())  return  vec2.zero;

   vec2  centerOfMass  =  agent.position;    for  (Agent  neighbor  :  neighbors)          centerOfMass  +=  neighbor.position;    centerOfMass  /=  neighbors.count();

   vec2  desired  =  centerOfMass  -­‐  agent.position;    desired  *=  agent.maxSpeed  /  desired.mag();

   vec2  force  =  desired  -­‐  agent.velocity;    return  force  *  (agent.maxForce  /  agent.maxSpeed);}

Tuesday, March 26, 13

Page 43: Crowd Simulation through Steering Behaviors and Flow Fieldstwvideo01.ubm-us.net/o1/vault/gdc2013/slides/... · Graham Pentheny Independent Game Developer & AI Researcher Crowd Simulation

Alignment

Tuesday, March 26, 13

Page 44: Crowd Simulation through Steering Behaviors and Flow Fieldstwvideo01.ubm-us.net/o1/vault/gdc2013/slides/... · Graham Pentheny Independent Game Developer & AI Researcher Crowd Simulation

vec2  Alignment(Agent  agent,  List<Agent>  neighbors)  {    if  (neighbors.empty())  return  vec2.zero;

   vec2  avgHeading  =  norm(  agent.velocity  );    for  (Agent  neighbor  :  neighbors)        avgHeading  +=  norm(  neighbor.velocity  );    avgHeading  /=  neighbors.count();

   vec2  desired  =  avgHeading  *  agent.maxSpeed;

   vec2  force  =  desired  -­‐  agent.velocity;    return  force  *  (agent.maxForce  /  agent.maxSpeed);}

Tuesday, March 26, 13

Page 45: Crowd Simulation through Steering Behaviors and Flow Fieldstwvideo01.ubm-us.net/o1/vault/gdc2013/slides/... · Graham Pentheny Independent Game Developer & AI Researcher Crowd Simulation

vec2  Alignment(Agent  agent,  List<Agent>  neighbors)  {    if  (neighbors.empty())  return  vec2.zero;

   vec2  avgHeading  =  norm(  agent.velocity  );    for  (Agent  neighbor  :  neighbors)        avgHeading  +=  norm(  neighbor.velocity  );    avgHeading  /=  neighbors.count();

   vec2  desired  =  avgHeading  *  agent.maxSpeed;

   vec2  force  =  desired  -­‐  agent.velocity;    return  force  *  (agent.maxForce  /  agent.maxSpeed);}

Tuesday, March 26, 13

Page 46: Crowd Simulation through Steering Behaviors and Flow Fieldstwvideo01.ubm-us.net/o1/vault/gdc2013/slides/... · Graham Pentheny Independent Game Developer & AI Researcher Crowd Simulation

vec2  Alignment(Agent  agent,  List<Agent>  neighbors)  {    if  (neighbors.empty())  return  vec2.zero;

   vec2  avgHeading  =  norm(  agent.velocity  );    for  (Agent  neighbor  :  neighbors)        avgHeading  +=  norm(  neighbor.velocity  );    avgHeading  /=  neighbors.count();

   vec2  desired  =  avgHeading  *  agent.maxSpeed;

   vec2  force  =  desired  -­‐  agent.velocity;    return  force  *  (agent.maxForce  /  agent.maxSpeed);}

Tuesday, March 26, 13

Page 47: Crowd Simulation through Steering Behaviors and Flow Fieldstwvideo01.ubm-us.net/o1/vault/gdc2013/slides/... · Graham Pentheny Independent Game Developer & AI Researcher Crowd Simulation

vec2  Alignment(Agent  agent,  List<Agent>  neighbors)  {    if  (neighbors.empty())  return  vec2.zero;

   vec2  avgHeading  =  norm(  agent.velocity  );    for  (Agent  neighbor  :  neighbors)        avgHeading  +=  norm(  neighbor.velocity  );    avgHeading  /=  neighbors.count();

   vec2  desired  =  avgHeading  *  agent.maxSpeed;

   vec2  force  =  desired  -­‐  agent.velocity;    return  force  *  (agent.maxForce  /  agent.maxSpeed);}

Tuesday, March 26, 13

Page 48: Crowd Simulation through Steering Behaviors and Flow Fieldstwvideo01.ubm-us.net/o1/vault/gdc2013/slides/... · Graham Pentheny Independent Game Developer & AI Researcher Crowd Simulation

Benefits●Pure functions●Defined in terms of arguments●No state or side effects●Concurrency is trivial & lock-free

●Flexible●Complexity through composition●Dynamically modify (LOD)

●Efficient●SIMD & Prioritization

Tuesday, March 26, 13

Page 49: Crowd Simulation through Steering Behaviors and Flow Fieldstwvideo01.ubm-us.net/o1/vault/gdc2013/slides/... · Graham Pentheny Independent Game Developer & AI Researcher Crowd Simulation

Debugging●Visual debugging information mandatory!●Collision shape●Movement direction●Net steering force●Current path direction

Tuesday, March 26, 13

Page 50: Crowd Simulation through Steering Behaviors and Flow Fieldstwvideo01.ubm-us.net/o1/vault/gdc2013/slides/... · Graham Pentheny Independent Game Developer & AI Researcher Crowd Simulation

Current Stigma●Inherently unstable●Necessitates constant tweaking and bugfixing●Stems from poor implementations

Tuesday, March 26, 13

Page 51: Crowd Simulation through Steering Behaviors and Flow Fieldstwvideo01.ubm-us.net/o1/vault/gdc2013/slides/... · Graham Pentheny Independent Game Developer & AI Researcher Crowd Simulation

Seek●Universally incorrect, except “Artificial Intelligence for Games” by Millington & Funge

vec2  seek(vec2  target,  Agent  a)  {        vec2  desired  =  target  -­‐  a.position;        desired  *=  a.maxSpeed  /  desired.mag();

       vec2  force  =  desired  -­‐  a.velocity;        return  force;  //  WRONG  -­‐  This  is  a  velocity!}

Tuesday, March 26, 13

Page 52: Crowd Simulation through Steering Behaviors and Flow Fieldstwvideo01.ubm-us.net/o1/vault/gdc2013/slides/... · Graham Pentheny Independent Game Developer & AI Researcher Crowd Simulation

Seek●Universally incorrect, except “Artificial Intelligence for Games” by Millington & Funge

vec2  seek(vec2  target,  Agent  a)  {        vec2  desired  =  target  -­‐  a.position;        desired  *=  a.maxSpeed  /  desired.mag();

       vec2  force  =  desired  -­‐  a.velocity;        return  force;  //  WRONG  -­‐  This  is  a  velocity!}

Tuesday, March 26, 13

Page 53: Crowd Simulation through Steering Behaviors and Flow Fieldstwvideo01.ubm-us.net/o1/vault/gdc2013/slides/... · Graham Pentheny Independent Game Developer & AI Researcher Crowd Simulation

Seek●Correct implementation defined in terms of max force

vec2  seek(vec2  target,  Agent  agent)  {        vec2  desired  =  target  -­‐  agent.position;        desired  *=  agent.maxSpeed  /  desired.mag();

       vec2  force  =  desired  -­‐  agent.velocity;        return  force  *  (agent.maxForce  /  agent.maxSpeed);}

Tuesday, March 26, 13

Page 54: Crowd Simulation through Steering Behaviors and Flow Fieldstwvideo01.ubm-us.net/o1/vault/gdc2013/slides/... · Graham Pentheny Independent Game Developer & AI Researcher Crowd Simulation

Flow fields + Steering●Inexpensive, robust crowd simulation●Flowfields●Best suited for common destinations in reasonably static environments●minimizes pathfinding calculations

●Steering●Behaviors Model specific kinds of movement●Complexity through composition

Tuesday, March 26, 13

Page 55: Crowd Simulation through Steering Behaviors and Flow Fieldstwvideo01.ubm-us.net/o1/vault/gdc2013/slides/... · Graham Pentheny Independent Game Developer & AI Researcher Crowd Simulation

Graham [email protected]

@grahamboree

slides available at: grahampentheny.com/gdc

Tuesday, March 26, 13

Page 56: Crowd Simulation through Steering Behaviors and Flow Fieldstwvideo01.ubm-us.net/o1/vault/gdc2013/slides/... · Graham Pentheny Independent Game Developer & AI Researcher Crowd Simulation

Andrew FrayProgrammer, Spry Fox

Steering with Context Behaviours

Tuesday, March 26, 13

Page 57: Crowd Simulation through Steering Behaviors and Flow Fieldstwvideo01.ubm-us.net/o1/vault/gdc2013/slides/... · Graham Pentheny Independent Game Developer & AI Researcher Crowd Simulation

Andrew Fray

Tuesday, March 26, 13

Page 58: Crowd Simulation through Steering Behaviors and Flow Fieldstwvideo01.ubm-us.net/o1/vault/gdc2013/slides/... · Graham Pentheny Independent Game Developer & AI Researcher Crowd Simulation

Steering behaviours

Tuesday, March 26, 13

Page 59: Crowd Simulation through Steering Behaviors and Flow Fieldstwvideo01.ubm-us.net/o1/vault/gdc2013/slides/... · Graham Pentheny Independent Game Developer & AI Researcher Crowd Simulation

●Lightweight framework

Steering behaviours

Tuesday, March 26, 13

Page 60: Crowd Simulation through Steering Behaviors and Flow Fieldstwvideo01.ubm-us.net/o1/vault/gdc2013/slides/... · Graham Pentheny Independent Game Developer & AI Researcher Crowd Simulation

●Lightweight framework●Simple behaviours

Steering behaviours

Tuesday, March 26, 13

Page 61: Crowd Simulation through Steering Behaviors and Flow Fieldstwvideo01.ubm-us.net/o1/vault/gdc2013/slides/... · Graham Pentheny Independent Game Developer & AI Researcher Crowd Simulation

●Lightweight framework●Simple behaviours●Emergent behaviour

Steering behaviours

Tuesday, March 26, 13

Page 62: Crowd Simulation through Steering Behaviors and Flow Fieldstwvideo01.ubm-us.net/o1/vault/gdc2013/slides/... · Graham Pentheny Independent Game Developer & AI Researcher Crowd Simulation

Drawbacks

Tuesday, March 26, 13

Page 63: Crowd Simulation through Steering Behaviors and Flow Fieldstwvideo01.ubm-us.net/o1/vault/gdc2013/slides/... · Graham Pentheny Independent Game Developer & AI Researcher Crowd Simulation

●No guaranteed movement constraint

Drawbacks

Tuesday, March 26, 13

Page 64: Crowd Simulation through Steering Behaviors and Flow Fieldstwvideo01.ubm-us.net/o1/vault/gdc2013/slides/... · Graham Pentheny Independent Game Developer & AI Researcher Crowd Simulation

●No guaranteed movement constraint●Inconsistent decisions

Drawbacks

Tuesday, March 26, 13

Page 65: Crowd Simulation through Steering Behaviors and Flow Fieldstwvideo01.ubm-us.net/o1/vault/gdc2013/slides/... · Graham Pentheny Independent Game Developer & AI Researcher Crowd Simulation

●No guaranteed movement constraint●Inconsistent decisions

Drawbacks

http://www.flickr.com/photos/sanithomas/6063443802/

Tuesday, March 26, 13

Page 66: Crowd Simulation through Steering Behaviors and Flow Fieldstwvideo01.ubm-us.net/o1/vault/gdc2013/slides/... · Graham Pentheny Independent Game Developer & AI Researcher Crowd Simulation

●No guaranteed movement constraint●Inconsistent decisions

http://www.flickr.com/photos/psykotrooper/7529582638/

Drawbacks

http://www.flickr.com/photos/sanithomas/6063443802/

Tuesday, March 26, 13

Page 67: Crowd Simulation through Steering Behaviors and Flow Fieldstwvideo01.ubm-us.net/o1/vault/gdc2013/slides/... · Graham Pentheny Independent Game Developer & AI Researcher Crowd Simulation

●No guaranteed movement constraint●Inconsistent decisions

http://www.flickr.com/photos/97302051@N00/2521446258/

Drawbacks

http://www.flickr.com/photos/sanithomas/6063443802/

Tuesday, March 26, 13

Page 68: Crowd Simulation through Steering Behaviors and Flow Fieldstwvideo01.ubm-us.net/o1/vault/gdc2013/slides/... · Graham Pentheny Independent Game Developer & AI Researcher Crowd Simulation

Balanced vectors problem

Tuesday, March 26, 13

Page 69: Crowd Simulation through Steering Behaviors and Flow Fieldstwvideo01.ubm-us.net/o1/vault/gdc2013/slides/... · Graham Pentheny Independent Game Developer & AI Researcher Crowd Simulation

Balanced vectors problem

Tuesday, March 26, 13

Page 70: Crowd Simulation through Steering Behaviors and Flow Fieldstwvideo01.ubm-us.net/o1/vault/gdc2013/slides/... · Graham Pentheny Independent Game Developer & AI Researcher Crowd Simulation

Balanced vectors problemChase behaviour

Tuesday, March 26, 13

Page 71: Crowd Simulation through Steering Behaviors and Flow Fieldstwvideo01.ubm-us.net/o1/vault/gdc2013/slides/... · Graham Pentheny Independent Game Developer & AI Researcher Crowd Simulation

Balanced vectors problemChase behaviour

Tuesday, March 26, 13

Page 72: Crowd Simulation through Steering Behaviors and Flow Fieldstwvideo01.ubm-us.net/o1/vault/gdc2013/slides/... · Graham Pentheny Independent Game Developer & AI Researcher Crowd Simulation

Balanced vectors problemChase behaviour

Tuesday, March 26, 13

Page 73: Crowd Simulation through Steering Behaviors and Flow Fieldstwvideo01.ubm-us.net/o1/vault/gdc2013/slides/... · Graham Pentheny Independent Game Developer & AI Researcher Crowd Simulation

Balanced vectors problemChase behaviourAvoid behaviour

Tuesday, March 26, 13

Page 74: Crowd Simulation through Steering Behaviors and Flow Fieldstwvideo01.ubm-us.net/o1/vault/gdc2013/slides/... · Graham Pentheny Independent Game Developer & AI Researcher Crowd Simulation

Balanced vectors problemChase behaviourAvoid behaviour

Tuesday, March 26, 13

Page 75: Crowd Simulation through Steering Behaviors and Flow Fieldstwvideo01.ubm-us.net/o1/vault/gdc2013/slides/... · Graham Pentheny Independent Game Developer & AI Researcher Crowd Simulation

Balanced vectors problemChase behaviourAvoid behaviour

Tuesday, March 26, 13

Page 76: Crowd Simulation through Steering Behaviors and Flow Fieldstwvideo01.ubm-us.net/o1/vault/gdc2013/slides/... · Graham Pentheny Independent Game Developer & AI Researcher Crowd Simulation

Balanced vectors problemChase behaviourAvoid behaviourSteer

Tuesday, March 26, 13

Page 77: Crowd Simulation through Steering Behaviors and Flow Fieldstwvideo01.ubm-us.net/o1/vault/gdc2013/slides/... · Graham Pentheny Independent Game Developer & AI Researcher Crowd Simulation

Balanced vectors problemChase behaviourAvoid behaviourSteer

Tuesday, March 26, 13

Page 78: Crowd Simulation through Steering Behaviors and Flow Fieldstwvideo01.ubm-us.net/o1/vault/gdc2013/slides/... · Graham Pentheny Independent Game Developer & AI Researcher Crowd Simulation

“Solutions”

Tuesday, March 26, 13

Page 79: Crowd Simulation through Steering Behaviors and Flow Fieldstwvideo01.ubm-us.net/o1/vault/gdc2013/slides/... · Graham Pentheny Independent Game Developer & AI Researcher Crowd Simulation

“Solutions”•Ignore Chase

Tuesday, March 26, 13

Page 80: Crowd Simulation through Steering Behaviors and Flow Fieldstwvideo01.ubm-us.net/o1/vault/gdc2013/slides/... · Graham Pentheny Independent Game Developer & AI Researcher Crowd Simulation

“Solutions”•Ignore Chase

Tuesday, March 26, 13

Page 81: Crowd Simulation through Steering Behaviors and Flow Fieldstwvideo01.ubm-us.net/o1/vault/gdc2013/slides/... · Graham Pentheny Independent Game Developer & AI Researcher Crowd Simulation

“Solutions”•Ignore Chase

Tuesday, March 26, 13

Page 82: Crowd Simulation through Steering Behaviors and Flow Fieldstwvideo01.ubm-us.net/o1/vault/gdc2013/slides/... · Graham Pentheny Independent Game Developer & AI Researcher Crowd Simulation

“Solutions”•Ignore Chase•Chase both targets

Tuesday, March 26, 13

Page 83: Crowd Simulation through Steering Behaviors and Flow Fieldstwvideo01.ubm-us.net/o1/vault/gdc2013/slides/... · Graham Pentheny Independent Game Developer & AI Researcher Crowd Simulation

“Solutions”•Ignore Chase•Chase both targets

Tuesday, March 26, 13

Page 84: Crowd Simulation through Steering Behaviors and Flow Fieldstwvideo01.ubm-us.net/o1/vault/gdc2013/slides/... · Graham Pentheny Independent Game Developer & AI Researcher Crowd Simulation

“Solutions”•Ignore Chase•Chase both targets•Validate target before chase

Tuesday, March 26, 13

Page 85: Crowd Simulation through Steering Behaviors and Flow Fieldstwvideo01.ubm-us.net/o1/vault/gdc2013/slides/... · Graham Pentheny Independent Game Developer & AI Researcher Crowd Simulation

“Solutions”•Ignore Chase•Chase both targets•Validate target before chase

Tuesday, March 26, 13

Page 86: Crowd Simulation through Steering Behaviors and Flow Fieldstwvideo01.ubm-us.net/o1/vault/gdc2013/slides/... · Graham Pentheny Independent Game Developer & AI Researcher Crowd Simulation

“Solutions”•Ignore Chase•Chase both targets•Validate target before chase

Tuesday, March 26, 13

Page 87: Crowd Simulation through Steering Behaviors and Flow Fieldstwvideo01.ubm-us.net/o1/vault/gdc2013/slides/... · Graham Pentheny Independent Game Developer & AI Researcher Crowd Simulation

“Solutions”•Ignore Chase•Chase both targets•Validate target before chase

Tuesday, March 26, 13

Page 88: Crowd Simulation through Steering Behaviors and Flow Fieldstwvideo01.ubm-us.net/o1/vault/gdc2013/slides/... · Graham Pentheny Independent Game Developer & AI Researcher Crowd Simulation

Design Flaw

Tuesday, March 26, 13

Page 89: Crowd Simulation through Steering Behaviors and Flow Fieldstwvideo01.ubm-us.net/o1/vault/gdc2013/slides/... · Graham Pentheny Independent Game Developer & AI Researcher Crowd Simulation

Merge contexts, not decisions

Tuesday, March 26, 13

Page 90: Crowd Simulation through Steering Behaviors and Flow Fieldstwvideo01.ubm-us.net/o1/vault/gdc2013/slides/... · Graham Pentheny Independent Game Developer & AI Researcher Crowd Simulation

Context Controller

Context Behaviour System

Tuesday, March 26, 13

Page 91: Crowd Simulation through Steering Behaviors and Flow Fieldstwvideo01.ubm-us.net/o1/vault/gdc2013/slides/... · Graham Pentheny Independent Game Developer & AI Researcher Crowd Simulation

Context Controller

Context Behaviour System

Context Behaviour

Context Behaviour

Context Behaviour

Context Behaviour

Tuesday, March 26, 13

Page 92: Crowd Simulation through Steering Behaviors and Flow Fieldstwvideo01.ubm-us.net/o1/vault/gdc2013/slides/... · Graham Pentheny Independent Game Developer & AI Researcher Crowd Simulation

Context Controller

Context Behaviour System

Context Behaviour

Context Behaviour

Context Behaviour

Context Behaviour

Context Map

Tuesday, March 26, 13

Page 93: Crowd Simulation through Steering Behaviors and Flow Fieldstwvideo01.ubm-us.net/o1/vault/gdc2013/slides/... · Graham Pentheny Independent Game Developer & AI Researcher Crowd Simulation

Context Controller

Context Behaviour System

Context Behaviour

Context Behaviour

Context Behaviour

Context Behaviour

Interest Map

Danger Map

Tuesday, March 26, 13

Page 94: Crowd Simulation through Steering Behaviors and Flow Fieldstwvideo01.ubm-us.net/o1/vault/gdc2013/slides/... · Graham Pentheny Independent Game Developer & AI Researcher Crowd Simulation

Context Controller

Context Behaviour System

Context Behaviour

Context Behaviour

Context Behaviour

Context Behaviour

Interest Map

Danger Map

Tuesday, March 26, 13

Page 95: Crowd Simulation through Steering Behaviors and Flow Fieldstwvideo01.ubm-us.net/o1/vault/gdc2013/slides/... · Graham Pentheny Independent Game Developer & AI Researcher Crowd Simulation

RESULT

Context Controller

Context Behaviour System

Context Behaviour

Context Behaviour

Context Behaviour

Context Behaviour

Tuesday, March 26, 13

Page 96: Crowd Simulation through Steering Behaviors and Flow Fieldstwvideo01.ubm-us.net/o1/vault/gdc2013/slides/... · Graham Pentheny Independent Game Developer & AI Researcher Crowd Simulation

Context maps

Tuesday, March 26, 13

Page 97: Crowd Simulation through Steering Behaviors and Flow Fieldstwvideo01.ubm-us.net/o1/vault/gdc2013/slides/... · Graham Pentheny Independent Game Developer & AI Researcher Crowd Simulation

Context maps

Tuesday, March 26, 13

Page 98: Crowd Simulation through Steering Behaviors and Flow Fieldstwvideo01.ubm-us.net/o1/vault/gdc2013/slides/... · Graham Pentheny Independent Game Developer & AI Researcher Crowd Simulation

Context maps

Tuesday, March 26, 13

Page 99: Crowd Simulation through Steering Behaviors and Flow Fieldstwvideo01.ubm-us.net/o1/vault/gdc2013/slides/... · Graham Pentheny Independent Game Developer & AI Researcher Crowd Simulation

Context maps

Tuesday, March 26, 13

Page 100: Crowd Simulation through Steering Behaviors and Flow Fieldstwvideo01.ubm-us.net/o1/vault/gdc2013/slides/... · Graham Pentheny Independent Game Developer & AI Researcher Crowd Simulation

Context controller

InterestDanger

Tuesday, March 26, 13

Page 101: Crowd Simulation through Steering Behaviors and Flow Fieldstwvideo01.ubm-us.net/o1/vault/gdc2013/slides/... · Graham Pentheny Independent Game Developer & AI Researcher Crowd Simulation

Plane behaviours

InterestDanger

Tuesday, March 26, 13

Page 102: Crowd Simulation through Steering Behaviors and Flow Fieldstwvideo01.ubm-us.net/o1/vault/gdc2013/slides/... · Graham Pentheny Independent Game Developer & AI Researcher Crowd Simulation

Chase behaviour

InterestDanger

Tuesday, March 26, 13

Page 103: Crowd Simulation through Steering Behaviors and Flow Fieldstwvideo01.ubm-us.net/o1/vault/gdc2013/slides/... · Graham Pentheny Independent Game Developer & AI Researcher Crowd Simulation

Chase behaviour

InterestDanger

Tuesday, March 26, 13

Page 104: Crowd Simulation through Steering Behaviors and Flow Fieldstwvideo01.ubm-us.net/o1/vault/gdc2013/slides/... · Graham Pentheny Independent Game Developer & AI Researcher Crowd Simulation

Chase behaviour

InterestDanger

Tuesday, March 26, 13

Page 105: Crowd Simulation through Steering Behaviors and Flow Fieldstwvideo01.ubm-us.net/o1/vault/gdc2013/slides/... · Graham Pentheny Independent Game Developer & AI Researcher Crowd Simulation

Chase behaviour

InterestDanger

Tuesday, March 26, 13

Page 106: Crowd Simulation through Steering Behaviors and Flow Fieldstwvideo01.ubm-us.net/o1/vault/gdc2013/slides/... · Graham Pentheny Independent Game Developer & AI Researcher Crowd Simulation

Chase behaviour

InterestDanger

Tuesday, March 26, 13

Page 107: Crowd Simulation through Steering Behaviors and Flow Fieldstwvideo01.ubm-us.net/o1/vault/gdc2013/slides/... · Graham Pentheny Independent Game Developer & AI Researcher Crowd Simulation

Chase behaviour

InterestDanger

Tuesday, March 26, 13

Page 108: Crowd Simulation through Steering Behaviors and Flow Fieldstwvideo01.ubm-us.net/o1/vault/gdc2013/slides/... · Graham Pentheny Independent Game Developer & AI Researcher Crowd Simulation

Chase behaviour

InterestDanger

Tuesday, March 26, 13

Page 109: Crowd Simulation through Steering Behaviors and Flow Fieldstwvideo01.ubm-us.net/o1/vault/gdc2013/slides/... · Graham Pentheny Independent Game Developer & AI Researcher Crowd Simulation

Chase behaviour

InterestDanger

Tuesday, March 26, 13

Page 110: Crowd Simulation through Steering Behaviors and Flow Fieldstwvideo01.ubm-us.net/o1/vault/gdc2013/slides/... · Graham Pentheny Independent Game Developer & AI Researcher Crowd Simulation

Chase behaviour

InterestDanger

Tuesday, March 26, 13

Page 111: Crowd Simulation through Steering Behaviors and Flow Fieldstwvideo01.ubm-us.net/o1/vault/gdc2013/slides/... · Graham Pentheny Independent Game Developer & AI Researcher Crowd Simulation

Avoid behaviour

InterestDanger

Tuesday, March 26, 13

Page 112: Crowd Simulation through Steering Behaviors and Flow Fieldstwvideo01.ubm-us.net/o1/vault/gdc2013/slides/... · Graham Pentheny Independent Game Developer & AI Researcher Crowd Simulation

Avoid behaviour

InterestDanger

Tuesday, March 26, 13

Page 113: Crowd Simulation through Steering Behaviors and Flow Fieldstwvideo01.ubm-us.net/o1/vault/gdc2013/slides/... · Graham Pentheny Independent Game Developer & AI Researcher Crowd Simulation

Processing the mapsDanger

Interest

Tuesday, March 26, 13

Page 114: Crowd Simulation through Steering Behaviors and Flow Fieldstwvideo01.ubm-us.net/o1/vault/gdc2013/slides/... · Graham Pentheny Independent Game Developer & AI Researcher Crowd Simulation

Processing the maps

X

Danger

InterestX XXX X

Tuesday, March 26, 13

Page 115: Crowd Simulation through Steering Behaviors and Flow Fieldstwvideo01.ubm-us.net/o1/vault/gdc2013/slides/... · Graham Pentheny Independent Game Developer & AI Researcher Crowd Simulation

Processing the maps

X

Danger

InterestX X

XX X

Tuesday, March 26, 13

Page 116: Crowd Simulation through Steering Behaviors and Flow Fieldstwvideo01.ubm-us.net/o1/vault/gdc2013/slides/... · Graham Pentheny Independent Game Developer & AI Researcher Crowd Simulation

Processing the maps

X

Danger

InterestX X

XX X

Tuesday, March 26, 13

Page 117: Crowd Simulation through Steering Behaviors and Flow Fieldstwvideo01.ubm-us.net/o1/vault/gdc2013/slides/... · Graham Pentheny Independent Game Developer & AI Researcher Crowd Simulation

Processing the maps

X

Danger

InterestX X

XX X

Tuesday, March 26, 13

Page 118: Crowd Simulation through Steering Behaviors and Flow Fieldstwvideo01.ubm-us.net/o1/vault/gdc2013/slides/... · Graham Pentheny Independent Game Developer & AI Researcher Crowd Simulation

Processing the maps

X

Danger

InterestX X

XX X

Tuesday, March 26, 13

Page 119: Crowd Simulation through Steering Behaviors and Flow Fieldstwvideo01.ubm-us.net/o1/vault/gdc2013/slides/... · Graham Pentheny Independent Game Developer & AI Researcher Crowd Simulation

Processing the maps

X

Danger

InterestX X

XX X

Tuesday, March 26, 13

Page 120: Crowd Simulation through Steering Behaviors and Flow Fieldstwvideo01.ubm-us.net/o1/vault/gdc2013/slides/... · Graham Pentheny Independent Game Developer & AI Researcher Crowd Simulation

Racing context map projection

Tuesday, March 26, 13

Page 121: Crowd Simulation through Steering Behaviors and Flow Fieldstwvideo01.ubm-us.net/o1/vault/gdc2013/slides/... · Graham Pentheny Independent Game Developer & AI Researcher Crowd Simulation

Racing context map projection

Tuesday, March 26, 13

Page 122: Crowd Simulation through Steering Behaviors and Flow Fieldstwvideo01.ubm-us.net/o1/vault/gdc2013/slides/... · Graham Pentheny Independent Game Developer & AI Researcher Crowd Simulation

Racing context map projection

Tuesday, March 26, 13

Page 123: Crowd Simulation through Steering Behaviors and Flow Fieldstwvideo01.ubm-us.net/o1/vault/gdc2013/slides/... · Graham Pentheny Independent Game Developer & AI Researcher Crowd Simulation

Racing context map projection

Tuesday, March 26, 13

Page 124: Crowd Simulation through Steering Behaviors and Flow Fieldstwvideo01.ubm-us.net/o1/vault/gdc2013/slides/... · Graham Pentheny Independent Game Developer & AI Researcher Crowd Simulation

Racing behaviours

Interest

Danger

Tuesday, March 26, 13

Page 125: Crowd Simulation through Steering Behaviors and Flow Fieldstwvideo01.ubm-us.net/o1/vault/gdc2013/slides/... · Graham Pentheny Independent Game Developer & AI Researcher Crowd Simulation

Racing line behaviour

Interest

Danger

Tuesday, March 26, 13

Page 126: Crowd Simulation through Steering Behaviors and Flow Fieldstwvideo01.ubm-us.net/o1/vault/gdc2013/slides/... · Graham Pentheny Independent Game Developer & AI Researcher Crowd Simulation

Racing line behaviour

Interest

Danger

Tuesday, March 26, 13

Page 127: Crowd Simulation through Steering Behaviors and Flow Fieldstwvideo01.ubm-us.net/o1/vault/gdc2013/slides/... · Graham Pentheny Independent Game Developer & AI Researcher Crowd Simulation

Interest

Danger

Avoid behaviour

Tuesday, March 26, 13

Page 128: Crowd Simulation through Steering Behaviors and Flow Fieldstwvideo01.ubm-us.net/o1/vault/gdc2013/slides/... · Graham Pentheny Independent Game Developer & AI Researcher Crowd Simulation

Interest

Danger

Avoid behaviour

Tuesday, March 26, 13

Page 129: Crowd Simulation through Steering Behaviors and Flow Fieldstwvideo01.ubm-us.net/o1/vault/gdc2013/slides/... · Graham Pentheny Independent Game Developer & AI Researcher Crowd Simulation

Draft behaviour

Interest

Danger

Tuesday, March 26, 13

Page 130: Crowd Simulation through Steering Behaviors and Flow Fieldstwvideo01.ubm-us.net/o1/vault/gdc2013/slides/... · Graham Pentheny Independent Game Developer & AI Researcher Crowd Simulation

Draft behaviour

Interest

Danger

Tuesday, March 26, 13

Page 131: Crowd Simulation through Steering Behaviors and Flow Fieldstwvideo01.ubm-us.net/o1/vault/gdc2013/slides/... · Graham Pentheny Independent Game Developer & AI Researcher Crowd Simulation

Processing the maps

Interest

Danger

Tuesday, March 26, 13

Page 132: Crowd Simulation through Steering Behaviors and Flow Fieldstwvideo01.ubm-us.net/o1/vault/gdc2013/slides/... · Graham Pentheny Independent Game Developer & AI Researcher Crowd Simulation

Processing the maps

Interest

Danger

Tuesday, March 26, 13

Page 133: Crowd Simulation through Steering Behaviors and Flow Fieldstwvideo01.ubm-us.net/o1/vault/gdc2013/slides/... · Graham Pentheny Independent Game Developer & AI Researcher Crowd Simulation

Processing the maps

Interest

Danger

X X X XX X X X

Tuesday, March 26, 13

Page 134: Crowd Simulation through Steering Behaviors and Flow Fieldstwvideo01.ubm-us.net/o1/vault/gdc2013/slides/... · Graham Pentheny Independent Game Developer & AI Researcher Crowd Simulation

Processing the maps

Interest

Danger

X X X X

X X X X

Tuesday, March 26, 13

Page 135: Crowd Simulation through Steering Behaviors and Flow Fieldstwvideo01.ubm-us.net/o1/vault/gdc2013/slides/... · Graham Pentheny Independent Game Developer & AI Researcher Crowd Simulation

Processing the maps

Interest

Danger

X X X X

✔ X X X X

Tuesday, March 26, 13

Page 136: Crowd Simulation through Steering Behaviors and Flow Fieldstwvideo01.ubm-us.net/o1/vault/gdc2013/slides/... · Graham Pentheny Independent Game Developer & AI Researcher Crowd Simulation

Processing the maps

Interest

Danger

X X X X

✔ X X X X

Tuesday, March 26, 13

Page 137: Crowd Simulation through Steering Behaviors and Flow Fieldstwvideo01.ubm-us.net/o1/vault/gdc2013/slides/... · Graham Pentheny Independent Game Developer & AI Researcher Crowd Simulation

Processing the maps

Interest

Danger

X X X X

✔ X X X X

Tuesday, March 26, 13

Page 138: Crowd Simulation through Steering Behaviors and Flow Fieldstwvideo01.ubm-us.net/o1/vault/gdc2013/slides/... · Graham Pentheny Independent Game Developer & AI Researcher Crowd Simulation

Smoothing decisions

Tuesday, March 26, 13

Page 139: Crowd Simulation through Steering Behaviors and Flow Fieldstwvideo01.ubm-us.net/o1/vault/gdc2013/slides/... · Graham Pentheny Independent Game Developer & AI Researcher Crowd Simulation

Smoothing decisions

Tuesday, March 26, 13

Page 140: Crowd Simulation through Steering Behaviors and Flow Fieldstwvideo01.ubm-us.net/o1/vault/gdc2013/slides/... · Graham Pentheny Independent Game Developer & AI Researcher Crowd Simulation

Smoothing decisions

Tuesday, March 26, 13

Page 141: Crowd Simulation through Steering Behaviors and Flow Fieldstwvideo01.ubm-us.net/o1/vault/gdc2013/slides/... · Graham Pentheny Independent Game Developer & AI Researcher Crowd Simulation

Smoothing decisions

Tuesday, March 26, 13

Page 142: Crowd Simulation through Steering Behaviors and Flow Fieldstwvideo01.ubm-us.net/o1/vault/gdc2013/slides/... · Graham Pentheny Independent Game Developer & AI Researcher Crowd Simulation

Performance

Tuesday, March 26, 13

Page 143: Crowd Simulation through Steering Behaviors and Flow Fieldstwvideo01.ubm-us.net/o1/vault/gdc2013/slides/... · Graham Pentheny Independent Game Developer & AI Researcher Crowd Simulation

Performance●Linear to context map size, behaviours

Tuesday, March 26, 13

Page 144: Crowd Simulation through Steering Behaviors and Flow Fieldstwvideo01.ubm-us.net/o1/vault/gdc2013/slides/... · Graham Pentheny Independent Game Developer & AI Researcher Crowd Simulation

Performance●Linear to context map size, behaviours●LOD out low priority behaviours

Tuesday, March 26, 13

Page 145: Crowd Simulation through Steering Behaviors and Flow Fieldstwvideo01.ubm-us.net/o1/vault/gdc2013/slides/... · Graham Pentheny Independent Game Developer & AI Researcher Crowd Simulation

Performance●Linear to context map size, behaviours●LOD out low priority behaviours●Vectorisation

Tuesday, March 26, 13

Page 146: Crowd Simulation through Steering Behaviors and Flow Fieldstwvideo01.ubm-us.net/o1/vault/gdc2013/slides/... · Graham Pentheny Independent Game Developer & AI Researcher Crowd Simulation

LODing

Tuesday, March 26, 13

Page 147: Crowd Simulation through Steering Behaviors and Flow Fieldstwvideo01.ubm-us.net/o1/vault/gdc2013/slides/... · Graham Pentheny Independent Game Developer & AI Researcher Crowd Simulation

LODing

Tuesday, March 26, 13

Page 148: Crowd Simulation through Steering Behaviors and Flow Fieldstwvideo01.ubm-us.net/o1/vault/gdc2013/slides/... · Graham Pentheny Independent Game Developer & AI Researcher Crowd Simulation

LODing

Tuesday, March 26, 13

Page 149: Crowd Simulation through Steering Behaviors and Flow Fieldstwvideo01.ubm-us.net/o1/vault/gdc2013/slides/... · Graham Pentheny Independent Game Developer & AI Researcher Crowd Simulation

LODing

Tuesday, March 26, 13

Page 150: Crowd Simulation through Steering Behaviors and Flow Fieldstwvideo01.ubm-us.net/o1/vault/gdc2013/slides/... · Graham Pentheny Independent Game Developer & AI Researcher Crowd Simulation

LODing

Tuesday, March 26, 13

Page 151: Crowd Simulation through Steering Behaviors and Flow Fieldstwvideo01.ubm-us.net/o1/vault/gdc2013/slides/... · Graham Pentheny Independent Game Developer & AI Researcher Crowd Simulation

LODing

Tuesday, March 26, 13

Page 152: Crowd Simulation through Steering Behaviors and Flow Fieldstwvideo01.ubm-us.net/o1/vault/gdc2013/slides/... · Graham Pentheny Independent Game Developer & AI Researcher Crowd Simulation

LODing

Tuesday, March 26, 13

Page 153: Crowd Simulation through Steering Behaviors and Flow Fieldstwvideo01.ubm-us.net/o1/vault/gdc2013/slides/... · Graham Pentheny Independent Game Developer & AI Researcher Crowd Simulation

Pre-processing Context Maps

Tuesday, March 26, 13

Page 154: Crowd Simulation through Steering Behaviors and Flow Fieldstwvideo01.ubm-us.net/o1/vault/gdc2013/slides/... · Graham Pentheny Independent Game Developer & AI Researcher Crowd Simulation

Pre-processing Context Maps●Smoothing

Tuesday, March 26, 13

Page 155: Crowd Simulation through Steering Behaviors and Flow Fieldstwvideo01.ubm-us.net/o1/vault/gdc2013/slides/... · Graham Pentheny Independent Game Developer & AI Researcher Crowd Simulation

Pre-processing Context Maps●Smoothing●Blend with previous frame

Tuesday, March 26, 13

Page 156: Crowd Simulation through Steering Behaviors and Flow Fieldstwvideo01.ubm-us.net/o1/vault/gdc2013/slides/... · Graham Pentheny Independent Game Developer & AI Researcher Crowd Simulation

Recap

Tuesday, March 26, 13

Page 157: Crowd Simulation through Steering Behaviors and Flow Fieldstwvideo01.ubm-us.net/o1/vault/gdc2013/slides/... · Graham Pentheny Independent Game Developer & AI Researcher Crowd Simulation

Recap●Create projection from decision space to 1D context map

Tuesday, March 26, 13

Page 158: Crowd Simulation through Steering Behaviors and Flow Fieldstwvideo01.ubm-us.net/o1/vault/gdc2013/slides/... · Graham Pentheny Independent Game Developer & AI Researcher Crowd Simulation

Recap●Create projection from decision space to 1D context map●Behaviours write world view into danger, interest maps

Tuesday, March 26, 13

Page 159: Crowd Simulation through Steering Behaviors and Flow Fieldstwvideo01.ubm-us.net/o1/vault/gdc2013/slides/... · Graham Pentheny Independent Game Developer & AI Researcher Crowd Simulation

Recap●Create projection from decision space to 1D context map

X X X

●Behaviours write world view into danger, interest maps●Evaluate maps for best decision

Tuesday, March 26, 13

Page 160: Crowd Simulation through Steering Behaviors and Flow Fieldstwvideo01.ubm-us.net/o1/vault/gdc2013/slides/... · Graham Pentheny Independent Game Developer & AI Researcher Crowd Simulation

Conclusion

Tuesday, March 26, 13

Page 161: Crowd Simulation through Steering Behaviors and Flow Fieldstwvideo01.ubm-us.net/o1/vault/gdc2013/slides/... · Graham Pentheny Independent Game Developer & AI Researcher Crowd Simulation

Conclusion●Small, stateless, decoupled behaviours

Tuesday, March 26, 13

Page 162: Crowd Simulation through Steering Behaviors and Flow Fieldstwvideo01.ubm-us.net/o1/vault/gdc2013/slides/... · Graham Pentheny Independent Game Developer & AI Researcher Crowd Simulation

Conclusion●Small, stateless, decoupled behaviours●Separated WHAT from HOW

Tuesday, March 26, 13

Page 163: Crowd Simulation through Steering Behaviors and Flow Fieldstwvideo01.ubm-us.net/o1/vault/gdc2013/slides/... · Graham Pentheny Independent Game Developer & AI Researcher Crowd Simulation

Conclusion●Small, stateless, decoupled behaviours●Separated WHAT from HOW●Emergent behaviour

Tuesday, March 26, 13

Page 164: Crowd Simulation through Steering Behaviors and Flow Fieldstwvideo01.ubm-us.net/o1/vault/gdc2013/slides/... · Graham Pentheny Independent Game Developer & AI Researcher Crowd Simulation

Conclusion●Small, stateless, decoupled behaviours●Separated WHAT from HOW●Emergent behaviour●Guaranteed movement constraint

Tuesday, March 26, 13

Page 165: Crowd Simulation through Steering Behaviors and Flow Fieldstwvideo01.ubm-us.net/o1/vault/gdc2013/slides/... · Graham Pentheny Independent Game Developer & AI Researcher Crowd Simulation

Conclusion●Small, stateless, decoupled behaviours●Separated WHAT from HOW●Emergent behaviour●Guaranteed movement constraint●Consistent decisions

Tuesday, March 26, 13

Page 166: Crowd Simulation through Steering Behaviors and Flow Fieldstwvideo01.ubm-us.net/o1/vault/gdc2013/slides/... · Graham Pentheny Independent Game Developer & AI Researcher Crowd Simulation

Conclusion●Small, stateless, decoupled behaviours●Separated WHAT from HOW●Emergent behaviour●Guaranteed movement constraint●Consistent decisions●Suitable for macro scale

Tuesday, March 26, 13

Page 167: Crowd Simulation through Steering Behaviors and Flow Fieldstwvideo01.ubm-us.net/o1/vault/gdc2013/slides/... · Graham Pentheny Independent Game Developer & AI Researcher Crowd Simulation

Andrew Fray●@tenpn●andrewfray.wordpress.com●about.me/andrew.fray

Graham Pentheny●@grahamboree●[email protected]●slides available at:

grahampentheny.com/gdc

Tuesday, March 26, 13