tactical-strategic

advertisement
Tactical & Strategic AI
John See
10 Jan 2011
Games Programming III (TGP2281) – T1, 2010/2011
Tactical & Strategic AI in Millington’s
Model
Games Programming III (TGP2281) – T1, 2010/2011
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)
• Some examples of use of waypoints to represent positions
in the level with unusual tactical features
• Normally the level designer have some say in this
Games Programming III (TGP2281) – T1, 2010/2011
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!
Games Programming III (TGP2281) – T1, 2010/2011
Tactical Points NOT THE BEST
pathfinding points
• 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
Games Programming III (TGP2281) – T1, 2010/2011
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 high-visibility points.
• A point can have both defensive and offensive tactical features.
Games Programming III (TGP2281) – T1, 2010/2011
Primitive and Compound Tactics
• For this e.g. how is an ambush point constructed from
primitive tactical locations?
Games Programming III (TGP2281) – T1, 2010/2011
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?
• What are some problems using waypoint graphs?
Games Programming III (TGP2281) – T1, 2010/2011
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
Games Programming III (TGP2281) – T1, 2010/2011
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 decisionmaking
3. Use tactical information during pathfinding to
produce character motion that is always tactically aware
Games Programming III (TGP2281) – T1, 2010/2011
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
• This method: Action decision is carried out first, then apply
tactical information to achieve its decision
• Some limitation in realism, and not able to use tactical
information to influence decision-making due to limited use.
Games Programming III (TGP2281) – T1, 2010/2011
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)
Games Programming III (TGP2281) – T1, 2010/2011
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)
Games Programming III (TGP2281) – T1, 2010/2011
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 non-tile-based
worlds, a grid can be imposed over the geometry for tactical
analyses.
Games Programming III (TGP2281) – T1, 2010/2011
Influence Maps
• Keeps track of current balance of military influence at each
location in level
• Factors… E.g. proximity of military unit, proximity of welldefended base, duration since a unit last occupied a
location, terrain, current financial state, weather, etc.
• In many games, simple influence maps are constructed
based on these popular factors:
1. Proximity of enemy units and bases
2. Relative military power
Games Programming III (TGP2281) – T1, 2010/2011
Influence Calculations
• Concept: Influence is taken to drop off with distance. The
farther away from a unit/base/etc., the lesser the value of
their influence
I0
• Linear model: I d 
1 d '
I0
I0
Id 
• Non-linear models: I d 
(1 d ' ) 2
1 d '
• In practice, linear drop off is perfectly reasonable, and is
also faster to compute
Games Programming III (TGP2281) – T1, 2010/2011
Influence Map Calculations
• To calculate the map, need to consider each unit in the
game for each location in the level.
• Up to billions of calculations may be needed! Execution
time: O(nm), Memory: O(m), where m number of
locations, n number of units.
• 3 approaches:
• Limited Radius of Effect
• Convolution Filters
• Map Flooding
Games Programming III (TGP2281) – T1, 2010/2011
Limited Radius of Effect
• LIMIT the radius of influence effect for each unit
• Each unit has a maximum radius of influence, beyond
that radius, no computation is required
• Use a threshold influence, It (beyond which influence is
zero), the radius is given by
I0
r
It 1
• This approach results in O(nr) in time, where r is number
of locations within the average radius of a unit. r << m
Much faster!
• Any disadvantages?
Games Programming III (TGP2281) – T1, 2010/2011
Example: Influence Map
Games Programming III (TGP2281) – T1, 2010/2011
Influence Map: Examples
• Influence maps allows AI to
see which areas of the game
are safe, which areas to
avoid, where the border
between teams are weakest
• Example: Security influence
map
Games Programming III (TGP2281) – T1, 2010/2011
Dealing with Unknowns
• Typically, games don’t allow players to see all the units in
the game. Vision can be additionally limited by hills and
other terrain features – Often known as “Fog-of-war”
• Should AIs have full knowledge of the entire map? Or
should they be subjected to “fog-of-war” as well?
• With the partial knowledge, one set of tactical analyses is
required per side in the game (incl. all AI sides).
Games Programming III (TGP2281) – T1, 2010/2011
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
Games Programming III (TGP2281) – T1, 2010/2011
Combining Tactical Analyses
Games Programming III (TGP2281) – T1, 2010/2011
Structure for Tactical Analyses
• Different types of tactical analyses can be distinguished
by its properties and frequency of updating needed
Games Programming III (TGP2281) – T1, 2010/2011
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.
Games Programming III (TGP2281) – T1, 2010/2011
Tactic Weights & Concern Blending
• In the previous equation, the real-valued quality 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 favoured
• 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 must be updated time-to-time.
Games Programming III (TGP2281) – T1, 2010/2011
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
Games Programming III (TGP2281) – T1, 2010/2011
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
Customizing
different
increased
to make weights
the unit for
choose
a more conservative
route units
back to base.
Games Programming III (TGP2281) – T1, 2010/2011
Implications on heuristic-based
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
Games Programming III (TGP2281) – T1, 2010/2011
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?
Games Programming III (TGP2281) – T1, 2010/2011
Multi-Tier AI – Top-Down Approach
• 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
Games Programming III (TGP2281) – T1, 2010/2011
Multi-Tier AI – Bottom-Up Approach
• 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, Squadbased Strategy games, Evolution-based games
• “Emergent cooperation”
Games Programming III (TGP2281) – T1, 2010/2011
Multi-Tier AI – Structural Example
At higher levels, decision making or tactics are performed.
At lower levels, pathfinding and movement behaviors carry
out high-level orders
Games Programming III (TGP2281) – T1, 2010/2011
Download