INTRO TO INTELLIGENT AND
AUTONOMOUS AGENTS



Steering behaviors and pathfinding
Game AI

 What we’re covering today
   And what we’re not
 How AI can improve your games
 Autonomous agents
Steering Behaviors

 What they are
 When they’re used
   Quite often
   http://www.youtube.com/watch?v=e2YYtSJhmJg
   Movies
 Let’s try some out!
Seek

 Move entity from current position to target
  position as quickly as possible
Our entity is the triangle. How do we get to the
target?
Desired velocity = target.position - myPosition
You can get a vector pointing from A to B by B - A
Ai part 1
Ai part 1
Don’t worry about
overshooting, it’ll be
corrected
Other steering behaviors

 Arrive
 Obstacle Avoidance


 Make sure we don’t have a force that’s too
  big!
Using SBs in your Entities

 ChasePlayer State
   Obstacle avoidance, Pursue or Seek
 Idle State
   Wander, maybe flocking?


 Sheep
   Flocking, Wander, Obstacle Avoidance, Evade
Steering behaviors ftw :?
Wouldn’t this be lovely? Well then, let’s find a path
A graph of points! (navigation graph)
Building a Nav Graph

 Goal: A list of nodes and edges
 What is needed:
   Start point, cast distance, interval
   (optional)Max number of nodes
Data Structures

GraphNode                              GraphEdge

Vector3 position                       GraphNode fromNode
GraphEdge[4] edges                     GraphFrom toNode
                                       (Float weight)
List<GraphNodes> Nodes

For ( i = 1; i <= xCastDistance; ++i)
      For (j = 1; j <= zCastDistance; ++j)
      {
            cast a ray downward from above for each potential neighbor node
            (i.e. (curX + invertal, curZ), (curX, curZ + interval), etc.)
            if raycast hit the ground
            {
                  new GraphNode(GraphNode(Raycast hit point))
                 if we haven’t already found this node
                 {
                        Add new graph node to Nodes
                 }

             (calculate edge cost)
             new GraphEdge(current node, new graph node, cost))
             Add new graph edge to the current node’s Edge list
         }
Start from initial position, start casting out!
Ai part 1
What happens when node cast hits out of bounds?
Ai part 1
New position
Nothing new, just adding another node/edge
:o A box!
Hit an object not tagged ground, skip it, keep moving
:OOOOO But we already processed that node!
Result depends on algorithm implementation. Easy route (the way the pseudo code was
setup) is to have each node responsible for itself. So in our case add the edge and ignore
the node.
Improvements Worth Mentioning

 Reducing node density
 Indexing GraphNodes and GraphEdges
Data Structures for Indexing

GraphNode                                         GraphEdge

int index                                         int fromNodeIndex
Vector3 position                                  int toNodeIndex
GraphEdge[4] mEdges                               float weight




  Instead of storing the GraphNodes that a GraphEdge is connected to, we
  store the index of each GraphNode, so we’re not storing a GraphNode twice
Take a look at that graph
Search Algorithms

 Depth-first search
 Breadth-first search
 Dijkstra’s algorithm
 A* (aka Dijkstra++)
   ^ yahtzee
Dijkstra’s Algorithm

 Usable with weighted graphs. Graphs without
  weight can be processed by assuming edges
  of equal weight
 Guaranteed to find shortest path, if it exists.
 Implementation
   Examine nodes on our search frontier, find the
    one with the smallest total weight, and add it to
    our path and keep going
Ai part 1
Ai part 1
Ai part 1
Ai part 1
Ai part 1
Ai part 1
Ai part 1
Picture from “Programming Game AI by Example” by Mat Buckland
Picture from “Programming Game AI by Example” by Mat Buckland
A*

 Dijkstra with an additional weight factor
  (heuristic)
   Heuristic: Making a decision based on some knowledge

 There’s something troublesome in the Dijsktra
  implementation that seems like it would be an
  easy fix
We know where our target is, so let’s
 approximate the cost from the nodes we are
 looking at to the target and factor that
 into what we choose
In this case, Euclidean distance
Manhattan Distance
Results
Picture from “Programming Game AI by Example” by Mat Buckland
Picture from “Programming Game AI by Example” by Mat Buckland
Review

 Steering behaviors
 Navigation graphs
 Search algorithms


 So how do they work together?
   You have a point on the graph you want to reach.
   You find a sequence of nodes to follow.
   Use steering behaviors to get from point to
    point, and create interesting behavior on the way
Next time…

 Organizing these lower level decisions into
  functional, autonomous agents (in a
  smart, extendable, debug-friendly way )

 Questions?

(can someone let Jordan know he can wake up now? kthx)

More Related Content

PPT
Graphical Objects and Scene Graphs
PPTX
CSS3 Animation for beginners - Imrokraft
PPT
Geometry Shader-based Bump Mapping Setup
PPTX
Class[1][23ed may] [algorithms]
PDF
Deep single view 3 d object reconstruction with visual hull
PPTX
Discrete Mathematics Presentation
PPTX
Class[5][9th jul] [three js-meshes_geometries_and_primitives]
PPT
CS 354 Transformation, Clipping, and Culling
Graphical Objects and Scene Graphs
CSS3 Animation for beginners - Imrokraft
Geometry Shader-based Bump Mapping Setup
Class[1][23ed may] [algorithms]
Deep single view 3 d object reconstruction with visual hull
Discrete Mathematics Presentation
Class[5][9th jul] [three js-meshes_geometries_and_primitives]
CS 354 Transformation, Clipping, and Culling

What's hot (19)

PPT
Shadow Volumes on Programmable Graphics Hardware
DOCX
The Speed of Two Objects
PDF
02 Geographic scripting in uDig - halfway between user and developer
PPTX
Machine Learning lecture2(linear regression)
PPTX
Texture mapping in_opengl
PPTX
Machine Learning lecture3(linear regression)
PPTX
Data structure
PPT
CS 354 Object Viewing and Representation
PDF
Opensource gis development - part 4
KEY
Artdm170 week12 user_interaction
PPT
CS 354 Texture Mapping
PPT
Image processing for robotics
PPTX
Spectral graph theory
PPTX
Class[6][5th aug] [three js-loaders]
PPT
CS 354 Pixel Updating
PDF
Unsupervised learning represenation with DCGAN
PPTX
Transfer learningforclp
PPTX
CSS3: Border And Colors
PDF
Andrew Goldberg. Highway Dimension and Provably Efficient Shortest Path Algor...
Shadow Volumes on Programmable Graphics Hardware
The Speed of Two Objects
02 Geographic scripting in uDig - halfway between user and developer
Machine Learning lecture2(linear regression)
Texture mapping in_opengl
Machine Learning lecture3(linear regression)
Data structure
CS 354 Object Viewing and Representation
Opensource gis development - part 4
Artdm170 week12 user_interaction
CS 354 Texture Mapping
Image processing for robotics
Spectral graph theory
Class[6][5th aug] [three js-loaders]
CS 354 Pixel Updating
Unsupervised learning represenation with DCGAN
Transfer learningforclp
CSS3: Border And Colors
Andrew Goldberg. Highway Dimension and Provably Efficient Shortest Path Algor...
Ad

Viewers also liked (8)

PPT
Presentation5
PPTX
Steering Behaviours: Wander
PDF
Driving simulators to support the design of autonomous vehicles
PDF
Massive Battle: Coordinated Movement of Autonomous Agents
PDF
AI in Games- Steering, Wander and Flocking behavior
PDF
Autonomous Agents on the Web: Beyond Linking and Meaning Mike Amundsen Keynot...
PPT
Mobile platform
DOC
Software engineering-quiz
Presentation5
Steering Behaviours: Wander
Driving simulators to support the design of autonomous vehicles
Massive Battle: Coordinated Movement of Autonomous Agents
AI in Games- Steering, Wander and Flocking behavior
Autonomous Agents on the Web: Beyond Linking and Meaning Mike Amundsen Keynot...
Mobile platform
Software engineering-quiz
Ad

Similar to Ai part 1 (20)

PDF
Graph Algorithms - Map-Reduce Graph Processing
PDF
Pathfinding - Part 3: Beyond the basics
PPTX
15-bellmanFord.pptx...........................................
PPTX
ppt 1.pptx
PDF
Link Prediction in the Real World
PDF
Pathfinding in games
PDF
Machine Learning in the Cloud with GraphLab
PDF
Lecture 16 - Dijkstra's Algorithm.pdf
PPTX
logic.pptx
PDF
Artificial Inteligence for Games an Overview SBGAMES 2012
PPTX
Graph Algorithms
PPTX
DATA STRUCTURES.pptx
PPTX
Deixtras Algorithm.pptxdjjdjdjdjddddddddddddddd
PDF
Node Path Visualizer Using Shortest Path Algorithms
PDF
Talk on Graph Theory - I
PPT
cs679-19.ppt aravaw afraaaarw aaw da adw
PPTX
Dijkstra
PDF
JAVA BASED VISUALIZATION AND ANIMATION FOR TEACHING THE DIJKSTRA SHORTEST PAT...
PPTX
130210107039 2130702
Graph Algorithms - Map-Reduce Graph Processing
Pathfinding - Part 3: Beyond the basics
15-bellmanFord.pptx...........................................
ppt 1.pptx
Link Prediction in the Real World
Pathfinding in games
Machine Learning in the Cloud with GraphLab
Lecture 16 - Dijkstra's Algorithm.pdf
logic.pptx
Artificial Inteligence for Games an Overview SBGAMES 2012
Graph Algorithms
DATA STRUCTURES.pptx
Deixtras Algorithm.pptxdjjdjdjdjddddddddddddddd
Node Path Visualizer Using Shortest Path Algorithms
Talk on Graph Theory - I
cs679-19.ppt aravaw afraaaarw aaw da adw
Dijkstra
JAVA BASED VISUALIZATION AND ANIMATION FOR TEACHING THE DIJKSTRA SHORTEST PAT...
130210107039 2130702

More from spartasoft (7)

PPTX
Interviewing and Getting a Job 101
KEY
Spartasoft Month Long Game Roundtable
PPT
Gpu presentation
PPT
GDC 2011 recap
PPT
Console development
PPT
Build some PR!
PPT
Unite 2010
Interviewing and Getting a Job 101
Spartasoft Month Long Game Roundtable
Gpu presentation
GDC 2011 recap
Console development
Build some PR!
Unite 2010

Recently uploaded (20)

PPTX
Diploma pharmaceutics notes..helps diploma students
PPTX
Thinking Routines and Learning Engagements.pptx
PPTX
Neurology of Systemic disease all systems
PDF
FYJC - Chemistry textbook - standard 11.
PPTX
Key-Features-of-the-SHS-Program-v4-Slides (3) PPT2.pptx
PDF
Health aspects of bilberry: A review on its general benefits
PDF
GSA-Past-Papers-2010-2024-2.pdf CSS examination
PDF
Disorder of Endocrine system (1).pdfyyhyyyy
PPTX
principlesofmanagementsem1slides-131211060335-phpapp01 (1).ppt
DOCX
THEORY AND PRACTICE ASSIGNMENT SEMESTER MAY 2025.docx
PDF
Laparoscopic Imaging Systems at World Laparoscopy Hospital
PPTX
operating_systems_presentations_delhi_nc
PPTX
ACFE CERTIFICATION TRAINING ON LAW.pptx
PPTX
ENGlishGrade8_Quarter2_WEEK1_LESSON1.pptx
PDF
African Communication Research: A review
PDF
CHALLENGES FACED BY TEACHERS WHEN TEACHING LEARNERS WITH DEVELOPMENTAL DISABI...
PDF
WHAT NURSES SAY_ COMMUNICATION BEHAVIORS ASSOCIATED WITH THE COMP.pdf
PDF
Horaris_Grups_25-26_Definitiu_15_07_25.pdf
PPTX
Power Point PR B.Inggris 12 Ed. 2019.pptx
PDF
POM_Unit1_Notes.pdf Introduction to Management #mba #bba #bcom #bballb #class...
Diploma pharmaceutics notes..helps diploma students
Thinking Routines and Learning Engagements.pptx
Neurology of Systemic disease all systems
FYJC - Chemistry textbook - standard 11.
Key-Features-of-the-SHS-Program-v4-Slides (3) PPT2.pptx
Health aspects of bilberry: A review on its general benefits
GSA-Past-Papers-2010-2024-2.pdf CSS examination
Disorder of Endocrine system (1).pdfyyhyyyy
principlesofmanagementsem1slides-131211060335-phpapp01 (1).ppt
THEORY AND PRACTICE ASSIGNMENT SEMESTER MAY 2025.docx
Laparoscopic Imaging Systems at World Laparoscopy Hospital
operating_systems_presentations_delhi_nc
ACFE CERTIFICATION TRAINING ON LAW.pptx
ENGlishGrade8_Quarter2_WEEK1_LESSON1.pptx
African Communication Research: A review
CHALLENGES FACED BY TEACHERS WHEN TEACHING LEARNERS WITH DEVELOPMENTAL DISABI...
WHAT NURSES SAY_ COMMUNICATION BEHAVIORS ASSOCIATED WITH THE COMP.pdf
Horaris_Grups_25-26_Definitiu_15_07_25.pdf
Power Point PR B.Inggris 12 Ed. 2019.pptx
POM_Unit1_Notes.pdf Introduction to Management #mba #bba #bcom #bballb #class...

Ai part 1

  • 1. INTRO TO INTELLIGENT AND AUTONOMOUS AGENTS Steering behaviors and pathfinding
  • 2. Game AI  What we’re covering today  And what we’re not  How AI can improve your games  Autonomous agents
  • 3. Steering Behaviors  What they are  When they’re used  Quite often  http://www.youtube.com/watch?v=e2YYtSJhmJg  Movies  Let’s try some out!
  • 4. Seek  Move entity from current position to target position as quickly as possible
  • 5. Our entity is the triangle. How do we get to the target?
  • 6. Desired velocity = target.position - myPosition
  • 7. You can get a vector pointing from A to B by B - A
  • 10. Don’t worry about overshooting, it’ll be corrected
  • 11. Other steering behaviors  Arrive  Obstacle Avoidance  Make sure we don’t have a force that’s too big!
  • 12. Using SBs in your Entities  ChasePlayer State  Obstacle avoidance, Pursue or Seek  Idle State  Wander, maybe flocking?  Sheep  Flocking, Wander, Obstacle Avoidance, Evade
  • 14. Wouldn’t this be lovely? Well then, let’s find a path
  • 15. A graph of points! (navigation graph)
  • 16. Building a Nav Graph  Goal: A list of nodes and edges  What is needed:  Start point, cast distance, interval  (optional)Max number of nodes
  • 17. Data Structures GraphNode GraphEdge Vector3 position GraphNode fromNode GraphEdge[4] edges GraphFrom toNode (Float weight)
  • 18. List<GraphNodes> Nodes For ( i = 1; i <= xCastDistance; ++i) For (j = 1; j <= zCastDistance; ++j) { cast a ray downward from above for each potential neighbor node (i.e. (curX + invertal, curZ), (curX, curZ + interval), etc.) if raycast hit the ground { new GraphNode(GraphNode(Raycast hit point)) if we haven’t already found this node { Add new graph node to Nodes } (calculate edge cost) new GraphEdge(current node, new graph node, cost)) Add new graph edge to the current node’s Edge list }
  • 19. Start from initial position, start casting out!
  • 21. What happens when node cast hits out of bounds?
  • 24. Nothing new, just adding another node/edge
  • 25. :o A box! Hit an object not tagged ground, skip it, keep moving
  • 26. :OOOOO But we already processed that node! Result depends on algorithm implementation. Easy route (the way the pseudo code was setup) is to have each node responsible for itself. So in our case add the edge and ignore the node.
  • 27. Improvements Worth Mentioning  Reducing node density  Indexing GraphNodes and GraphEdges
  • 28. Data Structures for Indexing GraphNode GraphEdge int index int fromNodeIndex Vector3 position int toNodeIndex GraphEdge[4] mEdges float weight Instead of storing the GraphNodes that a GraphEdge is connected to, we store the index of each GraphNode, so we’re not storing a GraphNode twice
  • 29. Take a look at that graph
  • 30. Search Algorithms  Depth-first search  Breadth-first search  Dijkstra’s algorithm  A* (aka Dijkstra++)  ^ yahtzee
  • 31. Dijkstra’s Algorithm  Usable with weighted graphs. Graphs without weight can be processed by assuming edges of equal weight  Guaranteed to find shortest path, if it exists.  Implementation  Examine nodes on our search frontier, find the one with the smallest total weight, and add it to our path and keep going
  • 39. Picture from “Programming Game AI by Example” by Mat Buckland
  • 40. Picture from “Programming Game AI by Example” by Mat Buckland
  • 41. A*  Dijkstra with an additional weight factor (heuristic)  Heuristic: Making a decision based on some knowledge  There’s something troublesome in the Dijsktra implementation that seems like it would be an easy fix
  • 42. We know where our target is, so let’s approximate the cost from the nodes we are looking at to the target and factor that into what we choose In this case, Euclidean distance
  • 44. Results Picture from “Programming Game AI by Example” by Mat Buckland
  • 45. Picture from “Programming Game AI by Example” by Mat Buckland
  • 46. Review  Steering behaviors  Navigation graphs  Search algorithms  So how do they work together?  You have a point on the graph you want to reach.  You find a sequence of nodes to follow.  Use steering behaviors to get from point to point, and create interesting behavior on the way
  • 47. Next time…  Organizing these lower level decisions into functional, autonomous agents (in a smart, extendable, debug-friendly way )  Questions? (can someone let Jordan know he can wake up now? kthx)

Editor's Notes

  • #4: Steering behaviors as low level movement logic, often used in combination with each other to create interesting behaviors for autonomous agents.A few weeks ago one of the AI programmers on Castlevania: LoS was talking about, well, AI in LoS. I found it interesting when he mentioned the birds on the crow witch was mostly a flocking behavior, with some tweaksFlocks of bats and herds of penguins in Batman Returns, movement of orc armies in Lord of the RingsWhile you won’t use everyone in every game, having an understanding of them and saving them in your back pocket can be extremely useful.
  • #15: It would be great to have a direct path to follow to get there, wouldn’t it? What do we need to accomplish this? First, we need a large
  • #18: If your graph isn’t going to utilize special terrain