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
Transcript of "Ai part 1"
1.
INTRO TO INTELLIGENT ANDAUTONOMOUS AGENTSSteering 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 thetarget?
9.
Other steering behaviors Arrive Obstacle Avoidance Make sure we don’t have a force that’s too big!
10.
Using SBs in your Entities ChasePlayer State Obstacle avoidance, Pursue or Seek Idle State Wander, maybe flocking? Sheep Flocking, Wander, Obstacle Avoidance, Evade
14.
Building a Nav Graph Goal: A list of nodes and edges What is needed: Start point, cast distance, interval (optional)Max number of nodes
15.
Data StructuresGraphNode GraphEdgeVector3 position GraphNode fromNodeGraphEdge[4] edges GraphFrom toNode (Float weight)
16.
List<GraphNodes> NodesFor ( 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 }
17.
Start from initial position, start casting out!
18.
What happens when node cast hits out of bounds?
21.
:o A box!Hit an object not tagged ground, skip it, keep moving
22.
:OOOOO But we already processed that node!Result depends on algorithm implementation. Easy route (the way the pseudo code wassetup) is to have each node responsible for itself. So in our case add the edge and ignorethe node.
24.
Data Structures for IndexingGraphNode GraphEdgeint index int fromNodeIndexVector3 position int toNodeIndexGraphEdge[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
27.
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
28.
Picture from “Programming Game AI by Example” by Mat Buckland
29.
Picture from “Programming Game AI by Example” by Mat Buckland
30.
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
31.
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 chooseIn this case, Euclidean distance
33.
ResultsPicture from “Programming Game AI by Example” by Mat Buckland
34.
Picture from “Programming Game AI by Example” by Mat Buckland
35.
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
36.
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)
A particular slide catching your eye?
Clipping is a handy way to collect important slides you want to go back to later.
Be the first to comment