Title: Artificial Intelligence in Games Week 7
1Artificial Intelligence in GamesWeek 7
- Steve Rabin
- steve.rabin_at_gmail.com
- www.aiwisdom.com/uw
2Pathfinding Integration Project
- How did it go?
- Any problems?
- How much time did it take?
3Euphoria Demo
4Tactics and Terrain Analysis
5Terrain Analysis
- Algorithmic analysis of terrain
- Automated with no human intervention
- Alternative to hard-coding regions of interest
- In general
- Are there spots on the terrain that are
advantageous to me? - How can these be determined algorithmically?
- Given the current terrain, how can I tease out
this info?
6Terrain AnalysisReal-Time Strategy Games
- What are static points of interest on an RTS map?
- What are dynamic points of interest during an RTS
battle?
7Terrain AnalysisReal-Time Strategy Games
- Chokepoints
- Barriers force units through narrow path
- Barriers can be cliffs, walls, water, etc.
- Ambush sites
- High terrain overlooking low terrain chokepoint
- Wall building sites
- Low cost for building walls
- Natural barriers so not much wall required
- Cliffs
- Water
- Edge of map
- Identify front of the battle
- Identify flanking routes
- Identify inferior forces
8Terrain AnalysisFirst-Person Shooter Games
- What are static points of interest in an FPS map?
- What are dynamic points of interest during an FPS
fight?
9Terrain AnalysisFirst-Person Shooter Games
- Cover points
- Shielding
- Darkness
- Sniper points
- Good cover point (shielding, darkness)
- Potential high visibility to a large area
- Rear coverage
- Height advantage
- Escape route
- Safe paths to move from area to area
- Low casualties in path
- Low visibility to other areas
- Good cover along path
- Line-of-sight vulnerability
- Stay out of other's line-of-sight
10Tactical Reasoning in a First-Person Shooter
- Visibility is a good tactical indicator
- Does spot provide cover?
- Front cover and rear cover?
- How safe is it?
- Does spot provide accessibility?
- Is a given spot good to shoot from?
- Can we escape easily?
- How dangerous is it?
11Tactical Reasoning with WaypointsHalf-Life 2
(first-person shooter)
- Implementation strategy
- Preprocess terrain, storing visibility info
- Can area A see area B?
- Store visibility info in waypoint nodes
- Node As ability to see every other node
- How would you store it?
12Tactical Reasoning with WaypointsStoring
Visibility Information
- Store visibility info with bit strings
- Can perform operations on groups
- and
- or
- not
13Tactical Reasoning with WaypointsSafe and
Dangerous Nodes
- Which locations are
- Potentially safe?
- Potentially dangerous?
- Safe pathfinding
- Penalize dangerous nodes
- These are node visibilities
- What about the actual enemies?
14Tactical Reasoning with WaypointsAttack
Positioning
- Visible nodes
- Show where you could attack from
- But no cover
- Better strategy
- Find a node to attack enemy X from
- Which is also shielded from other enemies
15Tactical Reasoning with WaypointsAttack
Positioning
- 1. Get nodes visible to selected enemy
- 2. Get nodes visible to other enemies
- 3. Get safe nodes to attack from 3 1 !2
16Tactical Reasoning with WaypointsAttack
Positioning
- Other strategies
- Take cover from everyone
- Find a safe node that is close to a completely
safe node (in case NPC needs to reload) - Flanking
- Eliminate attack points that the enemy is facing
- For sneaking up on enemies
17Tactical Reasoning with WaypointsStatic
Waypoint Analysis
- Determine danger of each node in a static
environment - Weight each node based on number of nodes that
can see it - If pathfinding takes into consideration
- Paths are less likely to be visible to enemies
18Tactical Reasoning with WaypointsStatic
Waypoint Analysis
- Nodes marked for visibility count
- Sniper nodes have high exposure next to nodes
with low exposure
19Tactical Reasoning with WaypointsPinch Points
and Squad Tactics
- Identify pinch points as ambush spots
- 1. Find node (N) with only two neighbors
- 2. One neighbor node must be in confined area
- 3. Nodes connected to other neighbor nodes are
ambush spots
20Tactical Reasoning with WaypointsLimitations
- Must use hierarchy of networks to reduce size of
bit strings - Ducking action can make some nodes both good
cover and good attack locations - Annotate these nodes
- Unidirectional connections makes it a little more
complicated - Density of waypoints impacts quality of reasoning
21Influence Mapping
22Influence Mapping
- Abstracts distribution of power
- 2D grid superimposed on terrain
- Unit strength is summed into grid cells
- Influence declines exponentially with distance
- Helps determine
- Weaknesses
- Neutral routes to flank enemy
- The front of the battle
23Influence MappingBasic Influence Map
24Influence MappingEngagement
25Influence MappingAnalysis of Options
26Influence MapsOther Uses
- SimCity
- Non-violent use
- Influence of crime, pollution, police, fire
stations, etc
27Spatial Database for Spatial Analysis
28Spatial Database for Spatial Analysis
- Generalize terrain reasoning with waypoints
- Use a grid instead
- Expand to capture dynamic features
- Capture other interesting aspects
29Spatial Database for Spatial AnalysisMany
Layers of Grids
- Visibility
- How many squares are visible
- Openness layer
- Proximity to static obstacles
- Cover layer
- Locations where AI can take cover from gunfire
- Area occupancy layer
- Number of units in an area
- Line-of-fire layer
- Direction that weapons are being aimed
- Light level layer
- Brightness or darkness of any spot
- Area search layer
- Spots that have been searched
30Spatial Database for Spatial AnalysisOpenness
Layer
31Spatial Database for Spatial AnalysisArea
Occupancy Layer
32Spatial Database for Spatial AnalysisLine-of-Fir
e Layer
33Spatial Database for Spatial AnalysisCombine
Layers
- Combat desirability layer
- Represents desirability of moving into any given
area in combat - Combines openness, static cover, area occupancy
layers
34Project 3Implement Terrain Analysis
- Due next week (May 19th)
- (100) Create at least 3 simple layers of grids
and 1 combined layer that can be toggled through
(with the "L" key) - Possible layers Openness Layer, Occupancy Layer,
Line-of-Fire Layer, Cover Area Layer, Area Search
Layer, and Combat Desirability Layer - Extra Credit (10) Have the agents use the
information to do something intelligent
35Squad Tactics
36Squad TacticsDecentralized vs Centralized
37Squad TacticsDecentralized Squad
38Squad TacticsDecentralized Squad
- Key points
- Extension of individual AI
- Easy to add to existing AI
- Robustly handles many situations
- Deals well with a variety of capabilities within
the team - Can be easily combined with scripted squad member
actions - Cooperation and group behavior emerges from
individual behaviors - Technique used in original Half-Life
39Squad TacticsDecentralized Squad
- void SoloAIThink()
- CombatSitiation sit
- GetSituation()
- sit-gtObserve()
-
- for each available action
- if(action.IsApplicable(sit))
-
- determine value of action
- in sit
- if better than best action,
- make best action
-
-
- execute best action()
- void SoloAIThink()
- CombatSitiation sit
- GetSituation()
- sit-gtObserve()
- sit-gtProcessTeamIntentions()
- sit-gtProcessTeamObservations()
- for each available action
- if(action.IsApplicable(sit))
-
- determine value of action
- in sit
- if better than best action,
- make best action
-
-
- nearbySqdMembers-gtAnnounceAction()
- execute best action()
-
40Squad TacticsSolo AI vs Squad Member
- Fire-and-maneuver behavior
- If too many static squad members, move up
- If too many engaging threat, won't stop to engage
same threat - Robust against squad member casualties
- Interactions easily translated to audio for
effect/realism
41Squad TacticsSquad Assault
- Tactical behavior (on top of fire/move)
- Stay close to cover
- Don't block other's line-of-fire
- Take weapon ability into account
- Maintain team cohesion / line-of-sight
- Spread out to avoid being a single target
- Keep a line-of-sight on enemy
42Squad Tactics Squad Assault Squad Members
Mental Picture
- For each squad member
- Current pos and activity
- Claimed destination
- Line-of-fire
- For each opponent
- Last known position and state
- Estimated position
- Squad members engaging this opponent
- Line-of-fire
- For other threats (grenades, fires)
- Known/estimated position
- Damage radius
43Squad Tactics Squad Assault with Four-Man Patrol
in Hostile Situation
44Squad TacticsLeader evaluating positions and
picking one (center, top)
45Squad TacticsExecuting L-Shaped Ambush
- Wait until enemy enters kill zone, aggressively
attack, pull back to predefined rally point - Problems
- Decentralized squad has trouble waiting until
right moment to attack. Attack moment requires
some kind of coordination - Squad lacks autonomy
- Can't create L-shape itself, can't abort if enemy
doesn't show up
46Squad TacticsDecentralized Squad (reference)
47Squad TacticsRelation Between Squad and Squad
Member
48Squad TacticsCentralized Approach
- Advantages
- Separates concerns reduces number of problems
each AI has to deal with - Saves CPU do computations once
- AIs can be specialized independently from each
other
49Squad TacticsCentralized Approach
- Authoritarian command style
- No "I" in "team"
- Squad can sacrifice a member to achieve a goal
- Squad member's view might conflict with squad's
objective - Told to defend a front, but sniper is behind
- Coaching command style
- Each squad member given tasks
- Can choose to ignore and tell squad he can't
comply - Deals with sniper case
- But squad members get distracted easily
50Squad TacticsSituation and Extracted Features
- Force ratio 53, line-of-fire ratio 21
51Squad TacticsFSM for Valid Maneuvers
- Avoids oscillations
- FSM prevents attacking before completing pullback
52Squad TacticsBounding Overwatch Pullback
- Tail Squad Members Behavior
- Teammates lay down suppression fire
53Squad TacticsBounding Overwatch Pullback
- Pullback path, Cover fire locations, and two
bounding moves in progress
54Squad TacticsStages of Performing a Maneuver
55Team Member AIAvoiding Friendly Fire
- If player is shooting, how can buddy AI avoid
friendly fire? - If player is moving around, how can buddy AI
avoid friendly fire?
56Team Member AIAvoiding Friendly Fire
57Planning
58Planning
- Find series of actions for AI that changes the
current configuration of the game world into a
target configuration - Planning allows innovative solutions when the
game world is sufficiently rich - Requires
- Planning algorithm
- World representation
- Choosing set of actions
- Action
- Preconditions
- Effects
59Planning
60Planning
- Config1 Target not dead
- Action Attack
- Config2 Target is dead, Weapon must be loaded
- Action Load Weapon
- Config3 Target is dead, Weapon loaded, Weapon
must be armed - Acton Draw Weapon
- Config4 Target is dead, Weapon is loaded, Weapon
is armed