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
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
}
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.
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
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
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
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)
Notas do Editor
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.
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
If your graph isn’t going to utilize special terrain