Tactical & Strategic AI

advertisement
TACTICAL & STRATEGIC AI
Tactical and Strategic
Reasoning
 Covers…
 Deducing tactical situations from sketchy
(limited) information
 Using tactical situations to make decisions
 Coordinating between multiple characters
 …and more….
Waypoint Tactics
• A waypoint – a single position in the game level
(“nodes”, “representative points” used for
pathfinding)
• To use waypoints tactically  need to add
more data to the nodes (not just location info)
• Waypoints can be used to represent positions
in the level with unusual tactical features (so
that characters are better positioned tactically)
• Normally the level designer has some say in
this…
Tactical Locations
• Waypoints used for tactical purposes are
sometimes called – “rally points” e.g.
• To mark a fixed safe location for character to
retreat if losing fight (defensive)
• To mark a pre-determined hiding spot that
can ambush or snipe incoming enemy
(offensive)
• To move secretly in shadow areas without
being detected (stealth)
• Many more…
Tactical Locations
Tactical Locations
 A game level consists of a large set of
waypoints, each labeled with tactical qualities
 If waypoints used for pathfinding, they will
also inherit other data such as connections
etc.
 Practically, tactical locations are not very
useful as part of a pathfinding graph…
 More efficient to have separate pathfinding graph
and tactical location set
Tactical Locations
• Although common to combine two sets of waypoints (one
for tactical, one for pathfinding), not efficient nor flexible
• E.g. Cover and sniping waypoint nodes are not useful for
pathfinding! Result in unrealistic movements within level
Primitive and Compound Tactics
• Most games have a set of pre-defined tactical
qualities (e.g. sniping, shadow, cover, etc.).
These are primitive defined tactics
• Combination of these primitive tactics result
in locations with compound tactical qualities.
• E.g. Sniper locations – Points that have
combination of both cover points and highvisibility points.
• A point can have both defensive and offensive
tactical features.
Primitive and Compound Tactics
 For this e.g. how is an ambush point
constructed from primitive tactical locations?
More Compound Tactics –
Waypoint Graphs
• Waypoints can be CONNECTED to form waypoint
graphs (similar to pathfinding graphs) when the
waypoints defined are not isolated/separated
• Where is the best spot for a hit-and-run move?
• Topological analysis
Continuous Tactics
• Marking locations with numerical values (able to
use fuzzy logic and probabilities) instead of
Boolean values
• E.g. A waypoint will have a value for cover feature
(0.7) and visibility feature (0.9)
• In choosing between a few cover points to go,
choose one that has better/higher value
• Using fuzzy logic rules can allow us to combine
these values, E.g.
• Sniper (value) = cover (value) AND visibility (value)
• Sniper = MIN(0.7, 0.9) = 0.7
Using Tactical Locations
• How do we build a tactical mechanism within
the character AI?
• Three approaches:
1. Controlling tactical movement (simple method)
2. Incorporate tactical information into decision-
making
3. Use tactical information during pathfinding to
produce character motion that is always tactically
aware
1. Tactical Movement
• Tactical waypoints are queried during game when
the character AI needs to make a tactical move
• E.g. Character needs to reload bullets, it queries
the tactical waypoints in the immediate area to
look for “nearest suitable location” to stop and
reload, before continuing
• Action decision is carried out first, then apply
tactical information to achieve its decision
• Limitation: Some realism, not able to use tactical
information to influence decision making
2. Tactical Information in
Decision-Making
• Give the “decision-maker” access to tactical information,
just like any other game world information
• DT example:
• SM: Trigger transitions only when certain waypoints are
available and/or fulfill required numeric value (if used)
3. Tactical Information
during Pathfinding
• Relatively simple extension of basic
pathfinding.
• Rather than finding shortest/quickest path, it
takes into consideration tactical situation of
game
• Simplest way is to manipulate graph
connection costs (by adding “tactical cost” to
locations that are dangerous or reducing
“tactical cost” at locations that are easy)
Finding nearby waypoints
 To use any of these approaches, a fast
method is needed to generate nearby
waypoints
 Given location of character, generate a list of
suitable waypoints in order of distance
 Methods to work out what objects are nearby 
Binary space partitions (BSP), quad-trees, multiresolution maps
Creating waypoints
 So far we assumed the waypoints are pre-
created (by developer or level designer), and
the properties have been decided
 This is the most common practice – 1) Actual
properties are decided, 2) context-sensitive
information placed at locations to be interpreted
later
 It is also possible to CALCULATE the tactical
properties of each location automatically –
cover, visibility, shadow points, etc.
Tactical Analyses
• Sometimes known as influence maps – a technique
pioneered and widely used in RTS games where the
AI keeps track of areas of military influence in game
• Can also be used in simulation/evolution games,
FPSs or MMOs
• Overwhelming majority of current implementations
are based on tile-based grid worlds. Even for nontile-based worlds, a grid can be imposed over the
geometry for tactical analyses.
• Already discussed In Pathfinding lesson
Revising Influence Maps
 Keeps track of “military” influence at each




location level
Calculations – Linear/non-linear drop-off
Limited radius of effect – to constrain
calculations to a finite circular area
Allows game AI to analyze the game level, for
strategic decision making
“Fog-of-war”
Combining Tactical Analyses
• Multi-layer analyses involved combining a few
influence maps into a composite influence map.
• Example: To find best location to build tower,
consider: Wide range of visibility, secured location,
far from other towers to avoid redundancy (3 maps)
• To get a single influence value, the 3 base tactical
analyses can be combined by multiplication (or
addition, etc.)
Quality = Security x Visibility x Distance
(or if tower influence is used instead of distance)
Quality = Security x Visibility
Tower Influence
Combining Tactical Analyses
Structure for Tactical
Analyses
 Different types of tactical analyses can be
distinguished by its properties and frequency
of updating needed
Tactical Pathfinding
• Similar to regular pathfinding (same techniques/
algos), only modification is the cost function used
– extended to tactical info
• Cost function influenced by two criteria:
1. Distance/time
2. Tactical Information
•
Cost of a connection given by a formula
C  D
 wiTi
i
where D is the distance/time of connection, wi is
the weighing factor for each tactic Ti and i is the
number of tactics supported.
Tactic Weights and Blending
• The value for each tactic is multiplied by a weighting
factor before summing into the final cost value.
• Locations with high tactics weight will be avoided
• Locations with low tactics weight will be favored
• Weights can be negative, BUT careful not to have
negative overall weight, which may result in negative
overall cost!
• Tactical costs can be pre-calculated if they are static
(terrain, visibility). If they are dynamic (military
power, number of units), they should be updated
from time-to-time
Customizing Weights
• In certain games, different units can have different sets of
tactical weights (w) based on their characteristic.
• Example: Reconnaissance units, light infantry, heavy artillery.
Tactical info: terrain difficulty, visibility, proximity of enemy
units
Customizing Weights
• Weights can also be customized according to
a unit’s aggression
• E.g. Healthy units finds paths in normal way.
When it is injured, the weight for proximity to
enemy can be increased to make the unit
choose a more conservative route back to
base.
Implications on heuristicbased pathfinding
• When modifying pathfinding heuristics
(especially for A*), make sure heuristic measure is
not reduced too much due to subtraction of
tactical costs, or increased too much due to
addition of tactical costs.
 May result in underestimating or overestimating
heuristic
Coordinated Action
• To coordinate multiple characters to cooperate
together to get their job done, some structure
need to be in place. Two categories:
1. Team/Group AI (a group of AI NPCs, fully AI)
2. Cooperative AI (AI cooperates with a human player in
a team)
• Common Qs:
• Should individual AIs “speak” to each other, and make
collective decisions?
• Should a central “command center/brain” give orders
and instructions to each individual AI?
• Can we have a bit of both?
Multi-Tier AI – Top-Down
• Highest level AI makes a decision, passes it
down to next level, which uses its instruction
to make its decision, and pass again down to
the lowest level
• Example: Military Hierarchy
Multi-Tier AI – Bottom-Up
• Lowest level AI algorithms take their own
initiative to make decisions, then use higher
level algorithms to provide information on
which they can base their actions
• Example: Autonomous decision making by
individual characters that can influence the
overall game: Squad-based Strategy games,
Evolution-based games
• “Emergent cooperation”
Multi-Tier AI – Example
 Multiple levels – Each character ha s its own AI, squads of
characters together will have a different set of AI
algorithms
Multi-Tier AI – Example
 Player involvement in group AI: Recognition of player
actions and passing down to next layers
 Intermediate layers between player and individual AIs
should rely on player action
 Decision making can act to complement player
Structuring Multi-Tier AI
 2 infrastructure components:
 A communication mechanism to transfer orders
from higher layers in the hierarchy downward:
Overall strategy, assigned targets, areas of avoid,
etc.
 A hierarchical scheduling system to execute the
correct behaviors at the right time, in the right
order, and only when required
Emergent Cooperation
 Less centralized, more free-flowing
 Characters take into account what other
characters are doing (e.g. moving together)
Emergent Cooperation
 E.g. FSM for four characters in a team –
provide mutual cover and working coherently
 If any member is removed, team operates as
usual
Download