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