Module 11 Spatial Reasoning

911 views
854 views

Published on

Spatial Reasoning lecture from my Game AI class

0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total views
911
On SlideShare
0
From Embeds
0
Number of Embeds
1
Actions
Shares
0
Downloads
0
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

Module 11 Spatial Reasoning

  1. 1. Artificial Intelligence for Video Games Kevin Dill [email_address] Jeff Zuccaro [email_address]
  2. 2. Some Words <ul><li>Guard Post • Trench Line </li></ul><ul><li>Bunker </li></ul><ul><li>Outflank • Multi-Pronged Attack </li></ul><ul><li>Surround • Ambush </li></ul><ul><li>Surprise Attack </li></ul><ul><li>Cover • Concealment </li></ul><ul><li>Scout • Observation Post </li></ul>
  3. 3. A Classic Example * <ul><li>The funnel: </li></ul>* Forbus, K., J.V. Mahoney, and K. Dill, “How Qualitative Spatial Reasoning Can Improve Strategy Game AIs,” IEEE Intelligent Systems , July/August 2002
  4. 4. Another Classic Example * <ul><li>The massed-fires problem: </li></ul>* Forbus, K., J.V. Mahoney, and K. Dill, “How Qualitative Spatial Reasoning Can Improve Strategy Game AIs,” IEEE Intelligent Systems , July/August 2002
  5. 5. What Is Terrain Analysis? <ul><li>Loosely defined, terrain analysis is the process of reasoning about the positions of things in the game world. </li></ul><ul><li>We may do this on the basis of the actual terrain (hills, mountains, forests, rivers, oceans, etc.) </li></ul><ul><li>We may also include the “man-made” things in the world – buildings, armies, etc. </li></ul>
  6. 6. More formally… * <ul><li>Qualitative representations carve up continuous properties into conceptually meaningful units </li></ul><ul><li>Qualitative spatial representations [a.k.a. terrain analysis] carve space into regions based on a combination of physical and task-specific constraints </li></ul>* Forbus, K., J.V. Mahoney, and K. Dill, “How Qualitative Spatial Reasoning Can Improve Strategy Game AIs,” IEEE Intelligent Systems , July/August 2002
  7. 7. Tactical Positions
  8. 8. Examples of Tactical Positions <ul><li>Cover (low/high) </li></ul><ul><li>Concealment </li></ul><ul><li>Sniper </li></ul><ul><li>Etc. </li></ul>
  9. 9. Implementation <ul><li>Designer placed waypoints </li></ul><ul><ul><li>The good: simple </li></ul></ul><ul><ul><li>The bad: incomplete coverage, errors can happen, lots of work </li></ul></ul><ul><li>Automatically generated </li></ul><ul><ul><li>The good: accurate, complete </li></ul></ul><ul><ul><li>The bad: expensive map analysis, bugs can happen, lots of work </li></ul></ul>
  10. 10. Automatic Generation <ul><li>Cover points </li></ul><ul><ul><li>Generally found relative to objects </li></ul></ul><ul><ul><li>Mark your objects up with rectangles that denote their cover characteristics </li></ul></ul><ul><li>Sniping points </li></ul><ul><ul><li>Just cover points far from the player? </li></ul></ul><ul><ul><li>Maybe consider height? Fields of fire? </li></ul></ul><ul><li>Concealment </li></ul><ul><ul><li>Use the lighting model to determine shadows </li></ul></ul><ul><ul><li>Other map characteristics (e.g. deep grass) </li></ul></ul>
  11. 11. Finding Nearby Points <ul><li>If you have a terrain analysis, look in nearby regions </li></ul><ul><li>If they’re in the path graph, use Dijkstra’s </li></ul><ul><li>Use a BSP tree or similar algorithm </li></ul>
  12. 12. Regions
  13. 13. Less Formal Definitions <ul><li>Region : An area of the map which is composed entirely of terrain with similar characteristics (e.g. forest, water, etc.) </li></ul><ul><li>Choke Point : A narrow area in the terrain which restricts movement. </li></ul><ul><li>Corridors & Free Spaces : One way of breaking up terrain, first proposed by Forbus et al, which has proven to be effective in games (e.g. Master of Orion 3 , War Leaders: Clash of Nations ) </li></ul>
  14. 14. Characteristics of Regions <ul><li>Homogenous </li></ul><ul><li>Not too big, not too small </li></ul><ul><li>Roughly convex </li></ul><ul><li>Know stuff: </li></ul><ul><ul><li>Contents (static and dynamic) </li></ul></ul><ul><ul><li>Traffic patterns </li></ul></ul><ul><ul><li>Last time viewed </li></ul></ul><ul><ul><li>Death history </li></ul></ul><ul><ul><li>Anything else that might be useful to your AI </li></ul></ul>
  15. 15. Generating Regions
  16. 16. When It’s Easy * <ul><li>For many maps, the subdivision is obvious </li></ul><ul><ul><li>Master of Orion 3: stars & star lanes </li></ul></ul><ul><ul><li>Games set indoors or underground tend to exhibit similar characteristics </li></ul></ul>* Dill, K. and A. Sramek, “Performing Qualitative Terrain Analysis in Master of Orion 3,” AI Game Programming Wisdom 2
  17. 17. Kohan II: Tile-Based Maps <ul><li>Tile based map </li></ul><ul><li>A rectangle is a collection of tiles, all with the same terrain type </li></ul><ul><li>A region contains one or more rectangles of the same terrain type </li></ul><ul><li>An island is the set of all connected regions of the same terrain type </li></ul>
  18. 18. Kohan II: Tiles
  19. 19. Kohan II: Rectangles
  20. 20. Kohan II: Regions
  21. 21. Kohan II: Islands 1 2 3
  22. 22. Kohan II: Choke Point Detection <ul><li>A region is a choke point if there exist two adjacent regions, A and B, such that you can not travel from A to B without passing through the region being tested </li></ul><ul><ul><li>Limit your search to a depth of ~5 regions </li></ul></ul>
  23. 23. Regions
  24. 24. Flood Fill * <ul><li>Can be used on tile-based or non-tile-based maps </li></ul><ul><li>Rapid to compute </li></ul><ul><ul><li>Company of Heroes uses this technique to dynamically create regions in real time </li></ul></ul><ul><li>May create weird looking regions (?) </li></ul><ul><li>Kohan 2 technique may not find choke points </li></ul>* Buckland, M, Programming Game AI by Example
  25. 25. Navigation Mesh * <ul><li>If you’re using a navigation mesh for path planning, use the cells as regions </li></ul><ul><li>Only works if the cells are appropriately sized & shaped, homogenous, etc. </li></ul><ul><li>If you’re not using a navigation mesh, you can use regions as a high level path planning abstraction </li></ul>* Buckland, M, Programming Game AI by Example
  26. 26. Image Processing * <ul><li>Select impassible terrain </li></ul><ul><li>Expand selection </li></ul><ul><li>Invert selection </li></ul><ul><li>Fill (Free Spaces) </li></ul><ul><li>Expand selection (Free Space borders) </li></ul><ul><li>Invert Selection </li></ul><ul><li>Deselect impassible </li></ul><ul><li>Fill (Choke Points) </li></ul>* Obelleiro, J. et al, “RTS Terrain Analysis: An Image Processing Approach,” AI Game Programming Wisdom 4
  27. 27. Intelligent Path Planning
  28. 28. Path Quality <ul><li>Army officers selecting a route consider the following: </li></ul><ul><ul><li>Distance – obviously, but generally the least importantly </li></ul></ul><ul><ul><li>Trafficability – how quickly/easily can I travel </li></ul></ul><ul><ul><li>Visibility – where can I be seen from, where can I see? </li></ul></ul><ul><ul><li>Fields of Fire – where can I be shot from, where can I shoot? </li></ul></ul><ul><li>Current games give no more than lip service to these concepts </li></ul>
  29. 29. Modifying Path Cost <ul><li>Adjust the cost of each edge in the path graph based on tactical considerations </li></ul><ul><li>Can greatly increase cost of A* search </li></ul><ul><ul><li>Cost of A* is a function of how closely your heuristic matches the actual travel cost </li></ul></ul><ul><ul><li>Perfect heuristic example </li></ul></ul><ul><ul><li>Swamp/grassland example </li></ul></ul>
  30. 30. Using Multiple Paths * <ul><li>Remember this: </li></ul>* Forbus, K., J.V. Mahoney, and K. Dill, “How Qualitative Spatial Reasoning Can Improve Strategy Game AIs,” IEEE Intelligent Systems , July/August 2002
  31. 31. Generating Path Candidates <ul><li>Dijkstra’s Algorithm can be used to find all paths out to some depth </li></ul><ul><li>Generally speaking, finding all paths is expensive, so… </li></ul><ul><ul><li>Prioritize queries, and time-slice the search to answer them </li></ul></ul><ul><ul><li>Use A* first, then following up with Dijkstra’s if the path is short enough </li></ul></ul><ul><ul><li>Instead of using Dijkstra’s, use A* to find a path to each corridor adjacent to your target </li></ul></ul>
  32. 32. Using Path Candidates <ul><li>Score all paths wrt trafficability, visibility, and fields of fire, take the best </li></ul><ul><li>Coordinate movement down multiple paths </li></ul><ul><ul><li>Improve overall flow </li></ul></ul><ul><ul><li>Launch simultaneous attacks </li></ul></ul><ul><li>Pick a random path </li></ul><ul><ul><li>The military taught me to never use the same path twice, lest I be ambushed </li></ul></ul>
  33. 33. Intelligent Expansion
  34. 34. Exact Border Calculation * <ul><li>Walk the graph of corridors & free spaces </li></ul><ul><li>Mark free spaces as: </li></ul><ul><ul><li>Inside/outside borders </li></ul></ul><ul><ul><li>Threatened </li></ul></ul><ul><ul><li>Contested </li></ul></ul>* Dill, K. and A. Sramek, “Performing Qualitative Terrain Analysis in Master of Orion 3,” AI Game Programming Wisdom 2
  35. 35. Estimated Border Calculation <ul><li>Generate an influence map extending out from each player’s cities / buildings </li></ul><ul><li>Influence levels indicate how strongly each player controls a particular location </li></ul><ul><li>Contested areas are those with high influence for more than one player </li></ul><ul><li>The result looks similar to Civilization IV </li></ul>
  36. 36. Expansion Considerations <ul><li>Consider the strategic implications of a build site </li></ul><ul><ul><li>Is it or will it be a contested area? </li></ul></ul><ul><ul><li>Is it inside or outside of my borders? </li></ul></ul><ul><ul><li>Does it increase or decrease the number of threatened areas? </li></ul></ul><ul><ul><li>Does it increase the territory that I control? </li></ul></ul><ul><ul><li>Does it protect important sites (home world)? </li></ul></ul><ul><ul><li>Is it inside enemy borders, or does it place an enemy area inside my borders? </li></ul></ul>
  37. 37. Military Considerations <ul><li>Defensive </li></ul><ul><ul><li>Focus fixed defenses in threatened and contested areas </li></ul></ul><ul><ul><ul><li>Building them in “safe” areas is generally a waste of resources </li></ul></ul></ul><ul><ul><ul><li>Even so, consider the magnitude of the threat when deciding what to build </li></ul></ul></ul><ul><ul><li>Build structures like walls to create choke points where none exist </li></ul></ul><ul><li>Offensive </li></ul><ul><ul><li>Place a high priority on securing contested areas and enemy areas inside your borders </li></ul></ul>
  38. 38. Intelligent Unit Placement & Maneuver
  39. 39. Observation Posts <ul><li>Place scout units out in positions to warn you of enemy movement </li></ul><ul><li>If game mechanics support it (or if you can talk designers into game mechanics that support it), you want them in concealed positions </li></ul><ul><li>On tightly constrained maps, one good position is at the far end of corridors that lead away from your border areas </li></ul>
  40. 40. Defensive Lines <ul><li>Many games feature units (e.g. artillery, archers, quarterbacks, etc) which have significant offensive ability but are vulnerable when attacked </li></ul><ul><li>Place stronger defensive units (e.g. infantry, swordsmen, or linebackers, respectively) in front of them </li></ul><ul><li>Do the same thing with defensive buildings (e.g. forts, bunkers) and economic buildings (e.g. gold mines, HQ buildings) </li></ul>
  41. 41. More On Defensive Lines <ul><li>Place defensive units and structures to guard avenues of approach </li></ul><ul><ul><li>This is particularly effective on tightly constrained maps </li></ul></ul><ul><ul><li>Obelleiro et al* present an algorithm for positioning forces near choke points </li></ul></ul><ul><li>Place units and structures so that they are mutually supporting </li></ul><ul><ul><li>Don’t allow the enemy to mass his forces and pick them off one at a time (defeat in detail) </li></ul></ul>* Obelleiro, J. et al, “RTS Terrain Analysis: An Image Processing Approach,” AI Game Programming Wisdom 4
  42. 42. Flanking Attacks <ul><li>The classic infantry maneuver in almost all cases is to pin the enemy down from the front, then send a second force around the flank to finish them </li></ul><ul><li>Both of your forces can use cover to protect them from enemy fire as they maneuver, but it is very difficult to get cover from two angles at once </li></ul>

×