1 / 22

Artificial Intelligence in Game Design

Artificial Intelligence in Game Design. Dynamic Path Planning Algorithms. Dynamic Path Planning. Not always plausible for NPC to have complete map for path planning “Fog of war” Player can only view part of map they have explored Same should be true for NPC Paths may change dynamically

mindy
Télécharger la présentation

Artificial Intelligence in Game Design

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. Artificial Intelligence in Game Design Dynamic Path Planning Algorithms

  2. Dynamic Path Planning • Not always plausible for NPC to have complete map for path planning • “Fog of war” • Player can only view part of map they have explored • Same should be true for NPC • Paths may change dynamically • Paths between moving cars • Must reevaluate paths each frame

  3. Map Exploration Key idea: • NPC only has map of some waypoints • NPC can still use heuristic to estimate distance from waypoints to goal in unexplored areas Goal in unexplored area Have heuristic estimate of distance to it from waypoint Waypoint in explored area Know shortest path to here explored

  4. Map Exploration • NPC should not know waypoints and edge costs until they have explored an adjacent waypoint • Gathering information has cost of moving to that location • Key question: Which waypoint should NPC move to next? Goal in unexplored area Have heuristic estimate of distance to it from newly found points Waypoint in explored area Reaching here has cost explored

  5. Best-first Search • Follow edge to waypoint with shortest estimated path to goal • Difference from A*: • Path cost from initial location to current location Wherenot factored in • That cost already incurred by reaching current location • Go to waypoint Wnext with minimum of: edgecost(Where, Wnext) + H(Wnext, Wgoal)

  6. Best-first Search Example 3 4 1 5 Chosen since 1 + 5 < 3 + 4 3 4 2 1 3 2 Chosen since 3 + 2 < 2 + 4

  7. Backtracking (LRTA*) • Heuristic may greatly underestimate actual distance to goal • High-cost terrain • Impassible obstacle in path • Best path may involve returning to some previous waypoint and taking another route • Backtrack to waypoint Wprev if: edgecost(Where, Wnext) + H(Wnext, Wgoal) > pathcost(Where, Wprev) + H(Wprev, Wgoal) Wprev Wnext Wgoal

  8. Backtracking Example 3 4 2 1 Close to goal, but requires crossing a river Estimated cost = 16 15 1 3 20 2 Best path involves backtracking to here Estimated cost = 5 + 4 = 9 Easy to reach, but on edge of cliff Estimated cost = 22

  9. Heuristics and Dynamic Pathfinding • Heuristic estimates too high may not find best path • May be plausible behavior for world with hidden passages or paths • Player can use knowledge of shortcuts to outrun NPC! Chosen since 1 + 5 < 3 + 4 4 3 1 10 Shortcut has actual cost = 3

  10. Heuristics and Dynamic Pathfinding • Heuristic estimates too low frequent backtracking • May be most plausible behavior for worlds with many obstacles • Can be amusing for player if done right! &*%!

  11. Pathfinding in Dynamic Graphs • Example: Racing games or other games involving traffic • Problems:Waypoints are movingEdges between waypoints may only exist temporarily This car may change lanes and cut off edge These waypoints are moving with car being passed

  12. Time-based Waypoints • Waypoints have time as well as location property • Location of waypoint • Time at which the character reaches the waypoint • Only way to deal with moving waypoints • Example: 2 different routes to same location W • Red route: reaches waypoint (W, 5) • Blue route: reaches waypoint (W, 7) Same location but different time component 5 1 1 5

  13. Time-based Waypoints • Problem: potentially infinite number of waypoints at same location with different time components • Car can change lanes multiple times at any point • Can go faster or slower, resulting in different arrival times • Green route reaches (W, 9) • Need heuristics to constrain choices • Often “greedy”, covering ground as fast as possible

  14. Simplifying Assumptions Racing heuristics: • If changing lanes, do so as soon as possible • Once in lane, move at maximum speed to next lane change Get here as fast as possible Change lanes as soon as safe

  15. Goal Points • Paths change rapidly • Other cars change lanes • Other cars change speeds • Can’t plan far in advance • Must put goals at small intervals • Every few hundred feet on track(possibly at inflection points) • Every block in city • Not necessarily point

  16. Safe Distances • Choose waypoints based on “safe distance” from other cars • Usually defined by some “radius” around cars • Can base safe radius on “personality” • Cautious • Normal • Aggressive • Psychotic Can’t cut in front of this car Can cut in front of this car Can’t get closer than this

  17. Dynamic Waypoints • Add waypoints for immediate lane changes from current position • Must be no cars within safe radius • Must take into account velocity of car • Can’t move directly sideways! • Must take into account speeds of cars in way Distance traveled in time to change lane Waypoint here blocked Distance blocking car travels

  18. Dynamic Waypoints • Add waypoints for positions immediately behind car in same lane • Based on speed difference between cars • Waypoint for Seek behavior without slowing down • Used if immediately steer into another lane without slowing down • Waypoint for Arrive behavior with matching velocity • Pulling up behind car without collision Where other car will be if Seek without slowing down Where other car will be if Arrive while slowing down Current position of other car

  19. Dynamic Waypoints • Add waypoints for positions where car can cut in front of cars in adjacent lanes • Based on speed difference between cars • Can’t be past car in current lane No waypoints past this car

  20. Dynamic Waypoints • Example combining all above waypoints • Each other car shown at position where it will be at waypoint formation Waypoints for immediate lane changes Waypoints for passing this car Waypoint for passing car in front Waypoint for pulling up behind car in front

  21. Creating Dynamic Graph • Next step: Continue on from these waypoints to next waypoints • Continue until nearest goal reached Goal

  22. Finding Best Path • Use Dijkstra or A* to find shortest path • Recompute each frame since things change • When reach this goal, start again for next goal Goal

More Related