Upload
gitel
View
259
Download
0
Embed Size (px)
DESCRIPTION
Game AI Steering Behavior & Group Movement ( 轉向行為 及 群體運動 ). Introduction. References Craig W. Reynolds 1987 “Flocks, Herds, and Schools: A Distributed Behavioral Model”, Siggraph’87 Proceedings 1999 “Steering Behaviors for Autonomous Characters”, GDC Proceedings* www.red3d.com/cwr/steer - PowerPoint PPT Presentation
Citation preview
1
Game AIGame AISteering Behavior &Steering Behavior &
Group MovementGroup Movement(( 轉向行為 及 群體運動轉向行為 及 群體運動 ))
ReferencesReferences– Craig W. ReynoldsCraig W. Reynolds– 1987 “Flocks, Herds, and Schools: A Distributed 1987 “Flocks, Herds, and Schools: A Distributed
Behavioral Model”, Siggraph’87 ProceedingsBehavioral Model”, Siggraph’87 Proceedings– 1999 “Steering Behaviors for Autonomous 1999 “Steering Behaviors for Autonomous
Characters”, GDC Proceedings*Characters”, GDC Proceedings*– www.red3d.com/cwr/steerwww.red3d.com/cwr/steer
Autonomous Characters (Autonomous Characters ( 自主自主角色角色 ))– Autonomous agentsAutonomous agents– NPCs in Games (Non-player characters, NPCs in Games (Non-player characters, 非玩家非玩家角色角色 ))
ApplicationsApplications– RoboticsRobotics– Artificial Intelligence (AI) (Artificial Intelligence (AI) ( 人工智能人工智能 ))– Artificial LifeArtificial Life
2
IntroductionIntroduction
Action selection (Action selection ( 行動選擇行動選擇 )) Steering (Steering ( 轉向轉向 )) Locomotion (Locomotion ( 運動運動 , , 移動移動 ))
3
Motion Behavior ( Motion Behavior ( 運動 行為 運動 行為 ))
A hierarchy of motion behavior
Game AI engineGame AI engine– Finite state machine ( Finite state machine ( 有限狀態機 有限狀態機 ))– Goals ( Goals ( 目的 目的 ))– Planning ( Planning ( 規劃 規劃 ))– Strategy ( Strategy ( 策略 策略 ))
Scripting ( Scripting ( 腳本 腳本 ) ) Assigned by playersAssigned by players
4
Action Selection (Action Selection ( 行動選擇 )
Path DeterminationPath Determination– Path finding or path planningPath finding or path planning
BehaviorsBehaviors– Seek & flee ( Seek & flee ( 尋找 及逃離尋找 及逃離 ))– Pursuit & evasion ( Pursuit & evasion ( 追尋 及逃避 追尋 及逃避 ))– Obstacle avoidance ( Obstacle avoidance ( 障礙迴避障礙迴避 ))– Wander ( Wander ( 徘徊 徘徊 ))– Path following ( Path following ( 路徑追蹤 路徑追蹤 ))– Unaligned collision avoidance ( Unaligned collision avoidance ( 非排列碰撞迴避 非排列碰撞迴避 ))Ref: http://www.red3d.com/cwr/steer/Ref: http://www.red3d.com/cwr/steer/
Group Steering Group Steering
5
Steering ( Steering ( 轉向 )
Character Physically-based ModelsCharacter Physically-based Models MovementMovement
– Turn Right, Move forward, …Turn Right, Move forward, … AnimationAnimation
– QuaternionQuaternion Implemented / Managed by Game EngineImplemented / Managed by Game Engine
6
LocomotionLocomotion
A Point MassA Point Mass– Linear momentumLinear momentum– No rotational momentumNo rotational momentum
ParametersParameters– MassMass– PositionPosition– VelocityVelocity
» Modified by applied forcesModified by applied forces» Max speedMax speed
Top speed of a vehicleTop speed of a vehicle
– Max steering forceMax steering force» Self-appliedSelf-applied
– OrientationOrientation» CarCar» AircraftAircraft
7
A Simple Vehicle Model (1/2)A Simple Vehicle Model (1/2)
Local SpaceLocal Space– OriginOrigin– ForwardForward– UpUp– SideSide
Steering ForcesSteering Forces– AsymmetricalAsymmetrical
» Thrust ( Thrust ( 推力 推力 ))» Braking ( Braking ( 制動 制動 ))» Steering (Steering ( 轉向 轉向 ))
Velocity AlignmentVelocity Alignment– No slide (No slide ( 非滑動非滑動 ), spin ( ), spin ( 旋轉 旋轉 ), …), …– TurnTurn
8
A Simple Vehicle Model (2/2)A Simple Vehicle Model (2/2)
Steer_force = Truncate(Streer_direction, Steer_force = Truncate(Streer_direction, Max_force)Max_force)
Acceleration = Steer_force / massAcceleration = Steer_force / mass
Velocity = Truncate(Old_velocity + Velocity = Truncate(Old_velocity + Acceleration * Time_step, Max_speed)Acceleration * Time_step, Max_speed)
New_position = Old_position + Velocity * New_position = Old_position + Velocity * Time_stepTime_step
9
Euler IntegrationEuler Integration
Pursuit to a Pursuit to a Static TargetStatic Target– Steer a character toward to a target positionSteer a character toward to a target position
Seek Steering forceSeek Steering force– desired_velocity = normalize(target - desired_velocity = normalize(target -
position)*max_speedposition)*max_speed– steering = desired_velocity – velocitysteering = desired_velocity – velocity
““A moth buzzing a light bulb”A moth buzzing a light bulb” FleeFlee
– Inverse of SeekInverse of Seek VariantsVariants
– ArrivalArrival– Pursuit to a moving targetPursuit to a moving target
10
Seek & Flee BehaviorsSeek & Flee Behaviors
A Stopping RadiusA Stopping Radius– Outside the radius, arrival is identical to seekOutside the radius, arrival is identical to seek– Inside the radius, the speed is ramped down to zeroInside the radius, the speed is ramped down to zero
» target_offset = target – positiontarget_offset = target – position» distance = length(target_offset)distance = length(target_offset)» ramped_speed = max_speed*(distance/slowing_distance)ramped_speed = max_speed*(distance/slowing_distance)» clipped_speed = minimum(ramped_speed, max_speed)clipped_speed = minimum(ramped_speed, max_speed)» desired_velocity = (clipped_speed/distance)*target_offset desired_velocity = (clipped_speed/distance)*target_offset » steering = desired_velocity – Velocitysteering = desired_velocity – Velocity
11
Arrival BehaviorArrival Behavior
Target Character Target Character is is MovingMoving Apply Seek or Flee to the Target’s Predict Apply Seek or Flee to the Target’s Predict
PositionPosition Estimate the Prediction Interval TEstimate the Prediction Interval T
– T = DcT = Dc– D = distance(Pursuer, Quarry)D = distance(Pursuer, Quarry)– c = turning parameterc = turning parameter
VariantsVariants– Offset pursuitOffset pursuit
» ““Fly by”Fly by”
12
Pursuit & Evasion BehaviorsPursuit & Evasion Behaviors
Use Bounding SphereUse Bounding Sphere Collision avoidanceCollision avoidance ProbeProbe
– A cylinder lying along forward axisA cylinder lying along forward axis– Diameter = character’s bounding sphereDiameter = character’s bounding sphere– Length = speed (means Alert range)Length = speed (means Alert range)
Find the most Threaten ObstacleFind the most Threaten Obstacle– Nearest intersected obstacleNearest intersected obstacle
Steering Steering
13
Obstacle Avoidance Behavior Obstacle Avoidance Behavior
Random SteeringRandom Steering One Solution :One Solution :
– Retain steering direction stateRetain steering direction state» Constrain steering force to the sphere surface located Constrain steering force to the sphere surface located
slightly ahead of the characterslightly ahead of the character
– Make small random displacements to it each frameMake small random displacements to it each frame» A small sphere on sphere surface to indicate and constrain A small sphere on sphere surface to indicate and constrain
the displacementthe displacement
Another one :Another one :– Perlin noisePerlin noise
VariantsVariants– ExploreExplore– ForageForage
14
Wander BehaviorWander Behavior
A PathA Path– SpineSpine
» A spline or poly-line to define the pathA spline or poly-line to define the path
– PipePipe» The tube or generated cylinder by a defined “radius”The tube or generated cylinder by a defined “radius”
FollowingFollowing– A velocity-based prediction positionA velocity-based prediction position
» Inside the tubeInside the tube Do nothing about steeringDo nothing about steering
» Outside the tubeOutside the tube ““Seek” to the on-path projectionSeek” to the on-path projection
15
Path Following BehaviorPath Following Behavior
VariantsVariants– Wall followingWall following– ContainmentContainment
A Flow Field Environment is DefinedA Flow Field Environment is Defined Virtual RealityVirtual Reality
– Not common in gamesNot common in games
16
Flow Field Following BehaviorFlow Field Following Behavior
Turn Away from Possible CollisionTurn Away from Possible Collision Predict the Potential CollisionPredict the Potential Collision
– Use bounding spheresUse bounding spheres If possibly collide,If possibly collide,
– Apply the steering on both charactersApply the steering on both characters– Steering direction is possible collision resultSteering direction is possible collision result
» Use “future” possible positionUse “future” possible position» The connected line between two sphere centersThe connected line between two sphere centers
17
Unaligned Collision Avoidance BehaviorUnaligned Collision Avoidance Behavior
Steering Behaviors Determining How the Steering Behaviors Determining How the Character Reacts to the Other Characters Character Reacts to the Other Characters within His Local Neighborhoodwithin His Local Neighborhood
The Behaviors includeThe Behaviors include– SeparationSeparation– CohesionCohesion– AlignmentAlignment
18
Steering Behaviors for Groups of CharactersSteering Behaviors for Groups of Characters
The Local Neighborhood is DefinedThe Local Neighborhood is Defined– A distanceA distance– The field-of-viewThe field-of-view
» AngleAngle
19
The Local Neighborhood of a CharacterThe Local Neighborhood of a Character
The Neighborhood
Make a Character to Maintain a Distance from Make a Character to Maintain a Distance from Others NearbyOthers Nearby– Compute the repulsive forces within local neighborhoodCompute the repulsive forces within local neighborhood
» Calculate the position vector for each nearbyCalculate the position vector for each nearby» Normalize itNormalize it» Weight the magnitude with distanceWeight the magnitude with distance
1/distance1/distance
» Sum the result forcesSum the result forces» Negate itNegate it 20
Separation BehaviorSeparation Behavior
Make a Character to Cohere with the others Make a Character to Cohere with the others NearbyNearby– Compute the cohesive forces within local Compute the cohesive forces within local
neighborhoodneighborhood» Compute the average position of the other nearbysCompute the average position of the other nearbys
Gravity centerGravity center
» Apply “Seek” to the positionApply “Seek” to the position
21
Cohesion BehaviorCohesion Behavior
Make a Character to Align with the Others Make a Character to Align with the Others NearbyNearby– Compute the steering forceCompute the steering force
» Average the velocity of all other characters nearbyAverage the velocity of all other characters nearby» The result is the desired velocityThe result is the desired velocity» Correct the current velocity to the desired one with the Correct the current velocity to the desired one with the
steering forcesteering force
22
Alignment BehaviorAlignment Behavior
Boids Model of FlocksBoids Model of Flocks– [Reynolds 87][Reynolds 87]
Combination ofCombination of– Separation steeringSeparation steering– Cohesion steeringCohesion steering– Alignment steeringAlignment steering
For Each CombinationFor Each Combination– A weight for combingA weight for combing– A distanceA distance– An AngleAn Angle
23
Flocking BehaviorFlocking Behavior
Follow a LeaderFollow a Leader– Stay with the leaderStay with the leader
» ““Pursuit” behavior (Arrival style)Pursuit” behavior (Arrival style)
– Stay out of the leader’s wayStay out of the leader’s way» Defined as “next position” with an extensionDefined as “next position” with an extension» ““Evasion” behavior when inside the above areaEvasion” behavior when inside the above area
– ““Separation” behavior for the followersSeparation” behavior for the followers
24
Leader Following behaviorLeader Following behavior
A Simple Vehicle Model with Local A Simple Vehicle Model with Local NeighborhoodNeighborhood
Common Steering BehaviorsCommon Steering Behaviors– SeekSeek– FleeFlee– PursuitPursuit– EvasionEvasion– Offset pursuitOffset pursuit– ArrivalArrival– Obstacle avoidanceObstacle avoidance– WanderWander– Path followingPath following
25
Behavior ConclusionBehavior Conclusion
– Wall followingWall following– ContainmentContainment– Flow field followingFlow field following– Unaligned collision Unaligned collision
avoidanceavoidance– SeparationSeparation– Cohesion (Cohesion ( 凝聚 ) ) – Alignment ( Alignment ( 隊列 ))– Flocking (Flocking ( 集群活動 ))– Leader followingLeader following
Combining BehaviorsCombining Behaviors