SlideShare una empresa de Scribd logo
1 de 30
Steering Behaviours for
Autonomous Agents
Dr Bryan Duggan
Dublin Institute of Technology
Introduction
• Normally a five week course (part of game AI)
• Maths prerequisites
– Coordinate geometry
– Vectors
– Matrices
– Physics
• There will be code
– https://github.com/skooter500/XNA-3D-Steering-
Behaviours-for-Space-Ships
• And now a short video…
What are Steering Behaviours?
• A framework for controlling autonomous agents
– Means of locomotion
– Largely independent
– Can be combined/turned on and off as the scenario changes
– Can be prioritised
– Improvisational and reactive
– Applications in games, movies and robotics
– Useful in modelling space simulations, nature, crowd scenes
– Amazingly fun, addictive and totally magical to code
History
• Invented by Craig Reynolds in
1983
• Flocks, herds and schools: A distributed
behavioral model (SIGGRAPH, 1987)
– Cited 5625 times!
• Stanley and Stella in Breaking the Ice (1987)
• Not bumping into things, (SIGGRAPH, 1988)
• Batman Returns (1992) (army of penguins)
• Steering behaviors for autonomous characters (GDC, 1999)
• Always presentations at the Games AI Summit at the GDC
• Used in many commercial games/movies
• Standard part of any game AI course
What is an autonomous agent?
• Maintains some state about itself
• Gets updated and drawn
• Behaviours are enabled and then the agent
behaves autonomously
• Can sense it’s environment
and respond
• An instance of a class
State
• Position (A Vector)
• Velocity (A Vector)
• Mass (A Scalar)
• Look, Up, Right (A Normal)
• World Transform (A Matrix)
• Quaternion (if you like!)
• Force, Acceleration (Vectors, calculated each frame)
• TimeDelta (A scalar, calculated each frame)
• Max_force, max_speed (Scalars, don’t change)
• List of behaviours
Integration
• force = steeringBehaviours.calculate();
• acceleration = force / mass;
• velocity += acceleration * timeDelta;
• speed = velocity.Length();
• position += velocity * timeDelta;
• if (speed > 0.001f)
look = velocity.Normalize();
Rotation in 2D/3D
• In 2D
– Calculate the rotation from the look vector
• In 3D
– Use a quaternion and full Hamiltonian integration
or…
– Apply “banking” to fake it
– Add some of the acceleration to the up vector
– Blend in over a number of frames
Seek
• desiredVelocity = targetPos - agent.Position;
• desiredVelocity.Normalize();
• desiredVelocity *= agent.maxSpeed;
• return (desiredVelocity - fighter.velocity);
Flee
• Flee is the opposite of seek. Instead of producing
a steering force to steer the agent toward a target
position, flee creates a force that steers the agent
away.
• The only difference is that the desiredVelocity is
calculated using a vector pointing in the opposite
direction (agent.Position - targetPos instead of
targetPos - agent.Position).
• Flee can be easily adjusted to generate a fleeing
force only when a vehicle comes within a certain
range of the target.
Pursue and Evade
• Based on underlying Seek and Flee
• Pursue – Predict future interception position of
target and seek that point
• Evade – Use future prediction as target to flee
from
Pursue
• dist = (agent.Target.Position -
agent.Position).Length();
• lookAhead = (dist / agent.maxSpeed);
• target = agent.Target.Position + (lookAhead *
agent.Target.velocity);
• return seek(target);
Arrive
• Goal to arrive at target
with zero velocity
• Arrival behaviour is
identical to seek while
the character is far from
its target.
• This behaviour causes the
character to slow down as it approaches the target,
eventually slowing to a stop coincident with the target
• Outside the stopping radius this desired velocity is
clipped to max_speed, inside the stopping radius,
desired velocity is ramped down (e.g. linearly) to zero.
• targetOffset = target - agent.Position;
• distance = targetOffset.Length();
• rampedSpeed = maxSpeed * (distance /
slowingDistance)
• clippedSpeed = minimum (ramped_speed,
max_speed)
• desiredVelocity = (clippedSpeed / distance) *
targetOffset
• return (desiredVelocity - agent.Velocity);
Wander
Offset pursuit
• Offset pursuit is useful for all kinds of situations.
Here are a few:
• Marking an opponent in a sports simulation
• Docking with a spaceship
• Shadowing an aircraft
• Implementing battle formations
Offset Pursuit
• target = Transform(offset,
agent.Leader.worldTransform);
• dist = (target - agent.Position).Length();
• lookAhead = (dist / agent.maxSpeed);
• target = target + (lookAhead *
agent.Leader.velocity);
• return arrive(target);
Wall avoidance (flat things)
• Create the feelers
– Take the default look vector * depth of the feeler
– Rotate it to create left, right ( Y Axis - yaw),
up and down (X Axis - pitch) feelers
– Transform to world space (* the world transform)
• Find out if each feeler penetrates the planes
– n.p + d
– If < 0, then it penetrates, so...
• Calculate the distance
– distance = abs(dotproduct (point, plane.normal) - plane.distance);
• Calculate the force
– n * distance
– Do this for each feeler and sum the forces
Obstacle Avoidance
• Steers a vehicle to avoid
obstacles lying in its path.
• Any object that can be
approximated by a circle or
sphere
• This is achieved by steering
the vehicle so as to keep a
rectangular area — a detection box, extending forward
from the vehicle — free of collisions.
• The detection box's width is equal to the bounding radius
of the vehicle, and its length is proportional to the vehicle's
current speed — the faster it goes, the longer the detection
box
Obstacle avoidance
The algorithm
• Calculate the box length
– minLength + (speed / maxSpeed * minLength)
• Tag obstacles in range of the box length
• For each tagged obstacle
– Transform into local space of the agent
• Multiply by inverse world transform
– Discard obstacles with +Z value as they will be behind the agent
– Expand the radius of the obstacle by half the agent radius
– Discard obstacles with an X or Y <> expanded radius
– Generate a ray from the origin and the basis vector
• We are in local space remember!
– Calculate the intersection point.
– Only consider the nearest intersecting obstacle
• Generate the forces
– Lateral on the X of the centre point of the agent
– Lateral on the Y of the centre point of the agent
– Breaking force on the Z of the centre point of the agent
– Transform by the agents world transform
A note on obstacle avoidance
• The most complicated of all the behaviours to code
• Lots of clever optimisations
• Ends up being several pages of code
• But beautiful!
• Intersection of a ray and a sphere
– (p – c).(p - c) - r2 = 0
– p(t) = p0 + tu
– a = u.u
– b = 2u(p0 – pc)
– c = (p0 – c).(p0 – c) - r2
Combining steering behaviours
• Sum
• Weighted sum
• * Weighted prioritised truncated running sum
• Prioritised dithering
Flocking
• * Separation
• * Cohesion
• * Alignment
• Wander
• Sphere Constrain
• Obstacle avoidance
• Flee
Seperation
• for (int i = 0; i < tagged.Count; i ++ )
• {
• entity = tagged[i];
• if (entity != null)
• {
• toEntity = agent.pos - entity.pos;
• steeringForce += (Normalize(toEntity) /
toEntity.Length());
• }
• }
• return steeringForce;
Cohesion
• foreach (Entity entity in tagged)
• {
• if (entity != agent)
• {
• centreOfMass += entity.Position;
• taggedCount++;
• }
• }
• if (taggedCount > 0)
• {
• centreOfMass /= taggedCount;
• steeringForce = seek(centreOfMass));
• }
• return steeringForce;
Alignment
• foreach (Entity entity in tagged)
• {
• if (entity != agent)
• {
• steeringForce += entity.look;
• taggedCount++;
• }
• }
• if (taggedCount > 0)
• {
• steeringForce /= (float) taggedCount;
• steeringForce = steeringForce - agent.look;
• }
• return steeringForce;
More information
• http://www.red3d.com/cwr/steer/
• https://github.com/skooter500/
• http://www.youtube.com/skooter500
• http://opensteer.sourceforge.net/
• http://arges-
systems.com/blog/2009/07/08/unitysteer-
steering-components-for-unity/
• http://natureofcode.com/
Thanks to
• Andy Duplain
• Neural Technologies Ltd
• for the Elite models

Más contenido relacionado

La actualidad más candente

Machine Learning - Object Detection and Classification
Machine Learning - Object Detection and ClassificationMachine Learning - Object Detection and Classification
Machine Learning - Object Detection and ClassificationVikas Jain
 
Features image processing and Extaction
Features image processing and ExtactionFeatures image processing and Extaction
Features image processing and ExtactionAli A Jalil
 
Pattern Recognition
Pattern RecognitionPattern Recognition
Pattern RecognitionMaaz Hasan
 
Visualization and Matplotlib using Python.pptx
Visualization and Matplotlib using Python.pptxVisualization and Matplotlib using Python.pptx
Visualization and Matplotlib using Python.pptxSharmilaMore5
 
Artificial Intelligence
Artificial IntelligenceArtificial Intelligence
Artificial IntelligenceMhd Sb
 
Artificial Neural Network seminar presentation using ppt.
Artificial Neural Network seminar presentation using ppt.Artificial Neural Network seminar presentation using ppt.
Artificial Neural Network seminar presentation using ppt.Mohd Faiz
 
KEY FRAME SYSTEM-Ruby Stella mary.pptx
KEY FRAME SYSTEM-Ruby Stella mary.pptxKEY FRAME SYSTEM-Ruby Stella mary.pptx
KEY FRAME SYSTEM-Ruby Stella mary.pptxComputerScienceDepar6
 
Image Restoration (Frequency Domain Filters):Basics
Image Restoration (Frequency Domain Filters):BasicsImage Restoration (Frequency Domain Filters):Basics
Image Restoration (Frequency Domain Filters):BasicsKalyan Acharjya
 
An introduction to Deep Learning
An introduction to Deep LearningAn introduction to Deep Learning
An introduction to Deep LearningJulien SIMON
 
Graphics pipelining
Graphics pipeliningGraphics pipelining
Graphics pipeliningAreena Javed
 
Top Libraries for Machine Learning with Python
Top Libraries for Machine Learning with Python Top Libraries for Machine Learning with Python
Top Libraries for Machine Learning with Python Chariza Pladin
 
Python for Data Science with Anaconda
Python for Data Science with AnacondaPython for Data Science with Anaconda
Python for Data Science with AnacondaTravis Oliphant
 
An Introduction to Deep Learning
An Introduction to Deep LearningAn Introduction to Deep Learning
An Introduction to Deep LearningPoo Kuan Hoong
 
Artificial Intelligence Searching Techniques
Artificial Intelligence Searching TechniquesArtificial Intelligence Searching Techniques
Artificial Intelligence Searching TechniquesDr. C.V. Suresh Babu
 
Mathematics Foundation Course for Machine Learning & AI By Eduonix
Mathematics Foundation Course for Machine Learning & AI By Eduonix Mathematics Foundation Course for Machine Learning & AI By Eduonix
Mathematics Foundation Course for Machine Learning & AI By Eduonix Nick Trott
 
Batch normalization presentation
Batch normalization presentationBatch normalization presentation
Batch normalization presentationOwin Will
 

La actualidad más candente (20)

Machine Learning - Object Detection and Classification
Machine Learning - Object Detection and ClassificationMachine Learning - Object Detection and Classification
Machine Learning - Object Detection and Classification
 
Features image processing and Extaction
Features image processing and ExtactionFeatures image processing and Extaction
Features image processing and Extaction
 
Pattern Recognition
Pattern RecognitionPattern Recognition
Pattern Recognition
 
Visualization and Matplotlib using Python.pptx
Visualization and Matplotlib using Python.pptxVisualization and Matplotlib using Python.pptx
Visualization and Matplotlib using Python.pptx
 
Artificial Intelligence
Artificial IntelligenceArtificial Intelligence
Artificial Intelligence
 
Planning
PlanningPlanning
Planning
 
Python programming : Abstract classes interfaces
Python programming : Abstract classes interfacesPython programming : Abstract classes interfaces
Python programming : Abstract classes interfaces
 
Artificial Neural Network seminar presentation using ppt.
Artificial Neural Network seminar presentation using ppt.Artificial Neural Network seminar presentation using ppt.
Artificial Neural Network seminar presentation using ppt.
 
KEY FRAME SYSTEM-Ruby Stella mary.pptx
KEY FRAME SYSTEM-Ruby Stella mary.pptxKEY FRAME SYSTEM-Ruby Stella mary.pptx
KEY FRAME SYSTEM-Ruby Stella mary.pptx
 
Image Restoration (Frequency Domain Filters):Basics
Image Restoration (Frequency Domain Filters):BasicsImage Restoration (Frequency Domain Filters):Basics
Image Restoration (Frequency Domain Filters):Basics
 
An introduction to Deep Learning
An introduction to Deep LearningAn introduction to Deep Learning
An introduction to Deep Learning
 
Noise Models
Noise ModelsNoise Models
Noise Models
 
Graphics pipelining
Graphics pipeliningGraphics pipelining
Graphics pipelining
 
Top Libraries for Machine Learning with Python
Top Libraries for Machine Learning with Python Top Libraries for Machine Learning with Python
Top Libraries for Machine Learning with Python
 
Python for Data Science with Anaconda
Python for Data Science with AnacondaPython for Data Science with Anaconda
Python for Data Science with Anaconda
 
An Introduction to Deep Learning
An Introduction to Deep LearningAn Introduction to Deep Learning
An Introduction to Deep Learning
 
AlexNet
AlexNetAlexNet
AlexNet
 
Artificial Intelligence Searching Techniques
Artificial Intelligence Searching TechniquesArtificial Intelligence Searching Techniques
Artificial Intelligence Searching Techniques
 
Mathematics Foundation Course for Machine Learning & AI By Eduonix
Mathematics Foundation Course for Machine Learning & AI By Eduonix Mathematics Foundation Course for Machine Learning & AI By Eduonix
Mathematics Foundation Course for Machine Learning & AI By Eduonix
 
Batch normalization presentation
Batch normalization presentationBatch normalization presentation
Batch normalization presentation
 

Similar a Introduction to Steering behaviours for Autonomous Agents

Artificial Inteligence for Games an Overview SBGAMES 2012
Artificial Inteligence for Games an Overview SBGAMES 2012Artificial Inteligence for Games an Overview SBGAMES 2012
Artificial Inteligence for Games an Overview SBGAMES 2012Bruno Duarte Corrêa
 
RubyKaigi2015 making robots-with-mruby
RubyKaigi2015 making robots-with-mrubyRubyKaigi2015 making robots-with-mruby
RubyKaigi2015 making robots-with-mrubyyamanekko
 
Lucio marcenaro tue summer_school
Lucio marcenaro tue summer_schoolLucio marcenaro tue summer_school
Lucio marcenaro tue summer_schoolJun Hu
 
Volumetric Lighting for Many Lights in Lords of the Fallen
Volumetric Lighting for Many Lights in Lords of the FallenVolumetric Lighting for Many Lights in Lords of the Fallen
Volumetric Lighting for Many Lights in Lords of the FallenBenjamin Glatzel
 
CSS3 TTA (Transform Transition Animation)
CSS3 TTA (Transform Transition Animation)CSS3 TTA (Transform Transition Animation)
CSS3 TTA (Transform Transition Animation)창석 한
 
Using CNTK's Python Interface for Deep LearningDave DeBarr -
Using CNTK's Python Interface for Deep LearningDave DeBarr - Using CNTK's Python Interface for Deep LearningDave DeBarr -
Using CNTK's Python Interface for Deep LearningDave DeBarr - PyData
 
Player Traversal Mechanics in the Vast World of Horizon Zero Dawn
Player Traversal Mechanics in the Vast World of Horizon Zero DawnPlayer Traversal Mechanics in the Vast World of Horizon Zero Dawn
Player Traversal Mechanics in the Vast World of Horizon Zero DawnGuerrilla
 
affine transformation for computer graphics
affine transformation for computer graphicsaffine transformation for computer graphics
affine transformation for computer graphicsDrSUGANYADEVIK
 
Putting the AI Back Into Air: Navigating the Air Space of Horizon Zero Dawn
Putting the AI Back Into Air: Navigating the Air Space of Horizon Zero DawnPutting the AI Back Into Air: Navigating the Air Space of Horizon Zero Dawn
Putting the AI Back Into Air: Navigating the Air Space of Horizon Zero DawnGuerrilla
 
Build Your Own VR Display Course - SIGGRAPH 2017: Part 2
Build Your Own VR Display Course - SIGGRAPH 2017: Part 2Build Your Own VR Display Course - SIGGRAPH 2017: Part 2
Build Your Own VR Display Course - SIGGRAPH 2017: Part 2StanfordComputationalImaging
 
08_게임 물리 프로그래밍 가이드
08_게임 물리 프로그래밍 가이드08_게임 물리 프로그래밍 가이드
08_게임 물리 프로그래밍 가이드noerror
 
Greg Hogan – To Petascale and Beyond- Apache Flink in the Clouds
Greg Hogan – To Petascale and Beyond- Apache Flink in the CloudsGreg Hogan – To Petascale and Beyond- Apache Flink in the Clouds
Greg Hogan – To Petascale and Beyond- Apache Flink in the CloudsFlink Forward
 
Advanced RxJS: Animations
Advanced RxJS: AnimationsAdvanced RxJS: Animations
Advanced RxJS: AnimationsBen Lesh
 
ScalaCheck
ScalaCheckScalaCheck
ScalaCheckBeScala
 
Rendering Art on the Web - A Performance compendium
Rendering Art on the Web - A Performance compendiumRendering Art on the Web - A Performance compendium
Rendering Art on the Web - A Performance compendiumRaimon Ràfols
 
Scene Graphs & Component Based Game Engines
Scene Graphs & Component Based Game EnginesScene Graphs & Component Based Game Engines
Scene Graphs & Component Based Game EnginesBryan Duggan
 

Similar a Introduction to Steering behaviours for Autonomous Agents (20)

Artificial Inteligence for Games an Overview SBGAMES 2012
Artificial Inteligence for Games an Overview SBGAMES 2012Artificial Inteligence for Games an Overview SBGAMES 2012
Artificial Inteligence for Games an Overview SBGAMES 2012
 
RubyKaigi2015 making robots-with-mruby
RubyKaigi2015 making robots-with-mrubyRubyKaigi2015 making robots-with-mruby
RubyKaigi2015 making robots-with-mruby
 
Lucio marcenaro tue summer_school
Lucio marcenaro tue summer_schoolLucio marcenaro tue summer_school
Lucio marcenaro tue summer_school
 
Volumetric Lighting for Many Lights in Lords of the Fallen
Volumetric Lighting for Many Lights in Lords of the FallenVolumetric Lighting for Many Lights in Lords of the Fallen
Volumetric Lighting for Many Lights in Lords of the Fallen
 
CSS3 TTA (Transform Transition Animation)
CSS3 TTA (Transform Transition Animation)CSS3 TTA (Transform Transition Animation)
CSS3 TTA (Transform Transition Animation)
 
Using CNTK's Python Interface for Deep LearningDave DeBarr -
Using CNTK's Python Interface for Deep LearningDave DeBarr - Using CNTK's Python Interface for Deep LearningDave DeBarr -
Using CNTK's Python Interface for Deep LearningDave DeBarr -
 
Robotics - introduction to Robotics
Robotics -  introduction to Robotics  Robotics -  introduction to Robotics
Robotics - introduction to Robotics
 
December 4, Project
December 4, ProjectDecember 4, Project
December 4, Project
 
Player Traversal Mechanics in the Vast World of Horizon Zero Dawn
Player Traversal Mechanics in the Vast World of Horizon Zero DawnPlayer Traversal Mechanics in the Vast World of Horizon Zero Dawn
Player Traversal Mechanics in the Vast World of Horizon Zero Dawn
 
affine transformation for computer graphics
affine transformation for computer graphicsaffine transformation for computer graphics
affine transformation for computer graphics
 
Putting the AI Back Into Air: Navigating the Air Space of Horizon Zero Dawn
Putting the AI Back Into Air: Navigating the Air Space of Horizon Zero DawnPutting the AI Back Into Air: Navigating the Air Space of Horizon Zero Dawn
Putting the AI Back Into Air: Navigating the Air Space of Horizon Zero Dawn
 
Build Your Own VR Display Course - SIGGRAPH 2017: Part 2
Build Your Own VR Display Course - SIGGRAPH 2017: Part 2Build Your Own VR Display Course - SIGGRAPH 2017: Part 2
Build Your Own VR Display Course - SIGGRAPH 2017: Part 2
 
08_게임 물리 프로그래밍 가이드
08_게임 물리 프로그래밍 가이드08_게임 물리 프로그래밍 가이드
08_게임 물리 프로그래밍 가이드
 
Lecture2
Lecture2Lecture2
Lecture2
 
Greg Hogan – To Petascale and Beyond- Apache Flink in the Clouds
Greg Hogan – To Petascale and Beyond- Apache Flink in the CloudsGreg Hogan – To Petascale and Beyond- Apache Flink in the Clouds
Greg Hogan – To Petascale and Beyond- Apache Flink in the Clouds
 
Advanced RxJS: Animations
Advanced RxJS: AnimationsAdvanced RxJS: Animations
Advanced RxJS: Animations
 
ScalaCheck
ScalaCheckScalaCheck
ScalaCheck
 
Rendering Art on the Web - A Performance compendium
Rendering Art on the Web - A Performance compendiumRendering Art on the Web - A Performance compendium
Rendering Art on the Web - A Performance compendium
 
Scene Graphs & Component Based Game Engines
Scene Graphs & Component Based Game EnginesScene Graphs & Component Based Game Engines
Scene Graphs & Component Based Game Engines
 
Performance patterns
Performance patternsPerformance patterns
Performance patterns
 

Más de Bryan Duggan

10 Years of Tunepal: Reflections & Future Directions
10 Years of Tunepal: Reflections & Future Directions10 Years of Tunepal: Reflections & Future Directions
10 Years of Tunepal: Reflections & Future DirectionsBryan Duggan
 
Object Oriented Programming
Object Oriented ProgrammingObject Oriented Programming
Object Oriented ProgrammingBryan Duggan
 
Tunepal: A cloud powered traditional music search engine
Tunepal: A cloud powered traditional music search engineTunepal: A cloud powered traditional music search engine
Tunepal: A cloud powered traditional music search engineBryan Duggan
 

Más de Bryan Duggan (6)

10 Years of Tunepal: Reflections & Future Directions
10 Years of Tunepal: Reflections & Future Directions10 Years of Tunepal: Reflections & Future Directions
10 Years of Tunepal: Reflections & Future Directions
 
Object Oriented Programming
Object Oriented ProgrammingObject Oriented Programming
Object Oriented Programming
 
Soc research
Soc researchSoc research
Soc research
 
Gw01 introduction
Gw01   introductionGw01   introduction
Gw01 introduction
 
Tunepal: A cloud powered traditional music search engine
Tunepal: A cloud powered traditional music search engineTunepal: A cloud powered traditional music search engine
Tunepal: A cloud powered traditional music search engine
 
Competitions
CompetitionsCompetitions
Competitions
 

Último

IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsEnterprise Knowledge
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)Gabriella Davis
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Igalia
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?Igalia
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Drew Madelung
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CVKhem
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slidevu2urc
 
A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024Results
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking MenDelhi Call girls
 
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxKatpro Technologies
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUK Journal
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘RTylerCroy
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptxHampshireHUG
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountPuma Security, LLC
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEarley Information Science
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Miguel Araújo
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking MenDelhi Call girls
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking MenDelhi Call girls
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreternaman860154
 

Último (20)

IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CV
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
 
A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men
 
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path Mount
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreter
 

Introduction to Steering behaviours for Autonomous Agents

  • 1. Steering Behaviours for Autonomous Agents Dr Bryan Duggan Dublin Institute of Technology
  • 2. Introduction • Normally a five week course (part of game AI) • Maths prerequisites – Coordinate geometry – Vectors – Matrices – Physics • There will be code – https://github.com/skooter500/XNA-3D-Steering- Behaviours-for-Space-Ships • And now a short video…
  • 3. What are Steering Behaviours? • A framework for controlling autonomous agents – Means of locomotion – Largely independent – Can be combined/turned on and off as the scenario changes – Can be prioritised – Improvisational and reactive – Applications in games, movies and robotics – Useful in modelling space simulations, nature, crowd scenes – Amazingly fun, addictive and totally magical to code
  • 4. History • Invented by Craig Reynolds in 1983 • Flocks, herds and schools: A distributed behavioral model (SIGGRAPH, 1987) – Cited 5625 times! • Stanley and Stella in Breaking the Ice (1987) • Not bumping into things, (SIGGRAPH, 1988) • Batman Returns (1992) (army of penguins) • Steering behaviors for autonomous characters (GDC, 1999) • Always presentations at the Games AI Summit at the GDC • Used in many commercial games/movies • Standard part of any game AI course
  • 5. What is an autonomous agent? • Maintains some state about itself • Gets updated and drawn • Behaviours are enabled and then the agent behaves autonomously • Can sense it’s environment and respond • An instance of a class
  • 6. State • Position (A Vector) • Velocity (A Vector) • Mass (A Scalar) • Look, Up, Right (A Normal) • World Transform (A Matrix) • Quaternion (if you like!) • Force, Acceleration (Vectors, calculated each frame) • TimeDelta (A scalar, calculated each frame) • Max_force, max_speed (Scalars, don’t change) • List of behaviours
  • 7. Integration • force = steeringBehaviours.calculate(); • acceleration = force / mass; • velocity += acceleration * timeDelta; • speed = velocity.Length(); • position += velocity * timeDelta; • if (speed > 0.001f) look = velocity.Normalize();
  • 8. Rotation in 2D/3D • In 2D – Calculate the rotation from the look vector • In 3D – Use a quaternion and full Hamiltonian integration or… – Apply “banking” to fake it – Add some of the acceleration to the up vector – Blend in over a number of frames
  • 9. Seek • desiredVelocity = targetPos - agent.Position; • desiredVelocity.Normalize(); • desiredVelocity *= agent.maxSpeed; • return (desiredVelocity - fighter.velocity);
  • 10. Flee • Flee is the opposite of seek. Instead of producing a steering force to steer the agent toward a target position, flee creates a force that steers the agent away. • The only difference is that the desiredVelocity is calculated using a vector pointing in the opposite direction (agent.Position - targetPos instead of targetPos - agent.Position). • Flee can be easily adjusted to generate a fleeing force only when a vehicle comes within a certain range of the target.
  • 11. Pursue and Evade • Based on underlying Seek and Flee • Pursue – Predict future interception position of target and seek that point • Evade – Use future prediction as target to flee from
  • 12. Pursue • dist = (agent.Target.Position - agent.Position).Length(); • lookAhead = (dist / agent.maxSpeed); • target = agent.Target.Position + (lookAhead * agent.Target.velocity); • return seek(target);
  • 13. Arrive • Goal to arrive at target with zero velocity • Arrival behaviour is identical to seek while the character is far from its target. • This behaviour causes the character to slow down as it approaches the target, eventually slowing to a stop coincident with the target • Outside the stopping radius this desired velocity is clipped to max_speed, inside the stopping radius, desired velocity is ramped down (e.g. linearly) to zero.
  • 14. • targetOffset = target - agent.Position; • distance = targetOffset.Length(); • rampedSpeed = maxSpeed * (distance / slowingDistance) • clippedSpeed = minimum (ramped_speed, max_speed) • desiredVelocity = (clippedSpeed / distance) * targetOffset • return (desiredVelocity - agent.Velocity);
  • 16. Offset pursuit • Offset pursuit is useful for all kinds of situations. Here are a few: • Marking an opponent in a sports simulation • Docking with a spaceship • Shadowing an aircraft • Implementing battle formations
  • 17. Offset Pursuit • target = Transform(offset, agent.Leader.worldTransform); • dist = (target - agent.Position).Length(); • lookAhead = (dist / agent.maxSpeed); • target = target + (lookAhead * agent.Leader.velocity); • return arrive(target);
  • 18. Wall avoidance (flat things) • Create the feelers – Take the default look vector * depth of the feeler – Rotate it to create left, right ( Y Axis - yaw), up and down (X Axis - pitch) feelers – Transform to world space (* the world transform) • Find out if each feeler penetrates the planes – n.p + d – If < 0, then it penetrates, so... • Calculate the distance – distance = abs(dotproduct (point, plane.normal) - plane.distance); • Calculate the force – n * distance – Do this for each feeler and sum the forces
  • 19. Obstacle Avoidance • Steers a vehicle to avoid obstacles lying in its path. • Any object that can be approximated by a circle or sphere • This is achieved by steering the vehicle so as to keep a rectangular area — a detection box, extending forward from the vehicle — free of collisions. • The detection box's width is equal to the bounding radius of the vehicle, and its length is proportional to the vehicle's current speed — the faster it goes, the longer the detection box
  • 21. The algorithm • Calculate the box length – minLength + (speed / maxSpeed * minLength) • Tag obstacles in range of the box length • For each tagged obstacle – Transform into local space of the agent • Multiply by inverse world transform – Discard obstacles with +Z value as they will be behind the agent – Expand the radius of the obstacle by half the agent radius – Discard obstacles with an X or Y <> expanded radius – Generate a ray from the origin and the basis vector • We are in local space remember! – Calculate the intersection point. – Only consider the nearest intersecting obstacle • Generate the forces – Lateral on the X of the centre point of the agent – Lateral on the Y of the centre point of the agent – Breaking force on the Z of the centre point of the agent – Transform by the agents world transform
  • 22. A note on obstacle avoidance • The most complicated of all the behaviours to code • Lots of clever optimisations • Ends up being several pages of code • But beautiful! • Intersection of a ray and a sphere – (p – c).(p - c) - r2 = 0 – p(t) = p0 + tu – a = u.u – b = 2u(p0 – pc) – c = (p0 – c).(p0 – c) - r2
  • 23. Combining steering behaviours • Sum • Weighted sum • * Weighted prioritised truncated running sum • Prioritised dithering
  • 24. Flocking • * Separation • * Cohesion • * Alignment • Wander • Sphere Constrain • Obstacle avoidance • Flee
  • 25.
  • 26. Seperation • for (int i = 0; i < tagged.Count; i ++ ) • { • entity = tagged[i]; • if (entity != null) • { • toEntity = agent.pos - entity.pos; • steeringForce += (Normalize(toEntity) / toEntity.Length()); • } • } • return steeringForce;
  • 27. Cohesion • foreach (Entity entity in tagged) • { • if (entity != agent) • { • centreOfMass += entity.Position; • taggedCount++; • } • } • if (taggedCount > 0) • { • centreOfMass /= taggedCount; • steeringForce = seek(centreOfMass)); • } • return steeringForce;
  • 28. Alignment • foreach (Entity entity in tagged) • { • if (entity != agent) • { • steeringForce += entity.look; • taggedCount++; • } • } • if (taggedCount > 0) • { • steeringForce /= (float) taggedCount; • steeringForce = steeringForce - agent.look; • } • return steeringForce;
  • 29. More information • http://www.red3d.com/cwr/steer/ • https://github.com/skooter500/ • http://www.youtube.com/skooter500 • http://opensteer.sourceforge.net/ • http://arges- systems.com/blog/2009/07/08/unitysteer- steering-components-for-unity/ • http://natureofcode.com/
  • 30. Thanks to • Andy Duplain • Neural Technologies Ltd • for the Elite models