1 / 22

Navigation and AI

Navigation and AI. Mark Nelson mjas@itu.dk. Movement and behaviors. In general, action in the world Some automated, some under player control Usually split into three categories Navigation, handled via navigation-specific methods Player behaviors, its own category of input/mechanic design

kohana
Download Presentation

Navigation and AI

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Navigation and AI • Mark Nelson • mjas@itu.dk Fall 2012 www.itu.dk

  2. Movement and behaviors In general, action in the world Some automated, some under player control Usually split into three categories Navigation, handled via navigation-specific methods Player behaviors, its own category of input/mechanic design NPC behaviors, core ”game AI”

  3. Navigation Find paths through the world Used by AI, but also often by humans Controlling every step is too tedious, want to get auto-routing Want flexibility, automation, efficiency, realism, …

  4. Classic grid-based navigation Square or hex tiles Entities fully occupy a tile: world is discrete Start at tile A, end at tile B Run a search algorithm to find a sequence of passable tiles that connect A and B

  5. General-purpose search algorithms Start from a root node From each node, have candidates we can add (add a tile to path) From each of those, have more candidates Forms a tree How do we traverse the tree to find a path through it?

  6. Breadth-first search Expand all 1-step possibilities Then all 1-step possibilities from those If a path of length n exists, we’ll find it on the nth expansion Guaranteed to find a solution, but may take substantial memory and time

  7. Depth-first search Expand a possibility Expand a possibility from there Repeat until we either find the goal, or hit a dead-end. Backtrack in the 2nd case. Much fewer memory requirements, but may go off into nowhere

  8. Iterative deepening Depth-first search with a depth limit Restart with a higher limit, if nothing found Effectively does a BFS using a DFS algorithm Less memory, but at the cost of redundant computation

  9. Bidirectional search Start simultaneously searching from both ends Two search trees, each on average half as deep

  10. Heuristic search Can search faster if we have a way of estimating distance In navigation, a minimum bound on distance is the distance if there weren’t any obstacles

  11. Greedy best-first search Expand to neighbor that is the closest estimated distance to the goal Fast, easy, but may find suboptimal solutions

  12. A* search Keep track of current distance to each frontier square Expand the neighbor that has the lowest sum of: Distance to that square Estimated remaining distance from the neighbor to goal Guaranteed to find the best solution if the heuristic never overestimates (”admissible heuristic”)

  13. Demo http://qiao.github.com/PathFinding.js/visual/

  14. Navigation meshes Instead of spaces, we can be at points, with some graph connectivity A grid can be seen as just a lattice navigation mesh Generalize to any shape

  15. Navigation meshes Large topic in itself, with some black art involved Limit case is fully continuous movement in arbitrary spaces Navmeshes try to look like that as much as possible, while computationally being like simple graph traversal

  16. Some navmesh questions Granularity Hierarchy Designer control vs. automated placement Who is responsible for the non-point size of avatars/NPCs? Standard A* search vs. specially coded routes

  17. NPC behavior Large area, encompassing big parts of game design General solution: scripting But often, want more structure and simpler solutions

  18. Finite state machines Simplest solution Fairly traditional, still used when lots of units w/ little computational resources to devote Units are in states, and situations cause them to transition E.g. patrol, get alarmed, chase

  19. Behavior trees Mix structure of FSMs with some of the more complex logic possible in general scripting Related to reactive planning Was introduced by Halo 2, and in a different form by Facade

  20. Behavior tree structure Leaves are primitive actions, like in an FSM Non-leaf nodes have control logic Kinds of control-logic nodes: Sequence Parallel Tests Decorators

  21. Further information Three-part introduction from AiGameDev: http://aigamedev.com/open/article/behavior-trees-part1/ http://aigamedev.com/open/article/behavior-trees-part2/ http://aigamedev.com/open/article/behavior-trees-part3/

  22. Project 3 Short/small project, due 6 November Have a square grid world, with some obstacles Two NPCs: One tries to pathfind with A* to the other NPC, ”wins” if it hits it The other one has an FSM that tries to avoid it

More Related