Similar presentations:
Building AI Sensory Systems
1. Building AI Sensory Systems
Lessons from Thief and Half-LifeTom Leonard
Valve
March 7, 2003
2. Introduction
• First-person, single-player AI• The basics using Half-Life
• Higher requirements of Thief: The
Dark Project
3. Senses Defined
• “Senses” is an engineering metaphor– Framework for understanding, design &
discussion
– Consistent with other metaphors in the
game world
– Readily understood by all members of the
development team
4. Senses Defined
• “Senses” is an engineering metaphor• Limited analogy
• Game design and technology limits are
problem domain, not world simulation
• Not computer vision
• Emulation, not simulation
5. Senses Defined
• The part of the AI that gathersinformation about items of interest in
the simulated environment of the
game
• Closely tied to knowledge
• Imbued with game design relevance
• May implement game logic
• Magnify value of simple decision
machines
6. Requirements
• Subservient to game design, efficientin implementation
• Only as complex as needed to be
entertaining and robust
• Must be perceivable and
understandable by player
• Not include senses impossible to
provide player feedback for
7. Half-Life
• Strong tactical and presentationelements
• Sight and hearing
• Information management
• Leverages basic senses into appealing
behaviors
8. The Basics
• “Look” at and “Listen” to the world– Active not passive
– Interest driven, seeing and hearing based
on rules
• Limiting work by leveraging game
design
• Can be event driven
9. Half-Life Sense Logic
If I am close to player then...Begin look
Gather a list of entities within a specified distance
For each entity found...
If I want to look for them and
If they are in my viewcone and
If I can raycast from my eyes to their eyes then...
If they are the player and
If I have been told to not see the player until they see me and
If they do not see me
End look
Else
Set various signals depending on my relationship with
the seen entity
End look
Begin listen
For each sound being played...
If the sound is carrying to my ears...
Add the sound to a list of heard sounds
If the sound is a real sound...
Set a signal indicating heard something
If the sound is a "smell" pseudo-sound
Set a signal indicating smelled something
End listen
10.
If I am close to player then...Begin look
Gather a list of entities within a specified distance
For each entity found...
If I want to look for them and
If they are in my viewcone and
If I can raycast from my eyes to their eyes then...
11.
If they are the player andIf I have been told to not see the player until
they see me and
If they do not see me
Continue to next entity
Else
Set various signals depending on my relationship
with the seen entity
End look
12.
Begin listenFor each sound being played...
If the sound is carrying to my ears...
Add the sound to a list of heard sounds
If the sound is a real sound...
Set a signal indicating heard something
If the sound is a "smell" pseudo-sound
Set a signal indicating smelled something
End listen
13. Observations
• Close relationship to purpose in game– Properties of the AI
– Relation to sensed object
– Relevance to player experience
• Optimization derived from game
mechanics
– Sensing limited to things that could
actually affect the player experience
14. Vision
• Vision– View distance
– View cone
– Line-of-sight
– Eye position
Player
AI
• Half-Life view
cones are 2D
• Unobstructed rays
mean visibility
15. Vision
• Operations ordered from least to mostexpensive
• Vision as a game of peek-a-boo
– Raycast from eye to eye
– Gets around weak sense of body in first
person
– Less relevant to other camera modes
16. Controlling senses for enjoyment If they are the player and If I have been told to not see the player until they see me and If
• Controlling senses for enjoymentIf they are the player and
If I have been told to not see the player
until
they see me and
If they do not see me
End look
• Small change to primitive system as
elegant solution to higher-level problem
17. Sound
• Simpler than vision• AI can often rely on existing soundrelated infrastructure
• AI job is determining that a sound is
relevant and heard, then assigning
meaning
18. Sound
• Sound as catchall for positionalevents
– Barney: “Hoo, something died down
here!”
– “Grenade!”
19. Thief: The Dark Project
• Stealth• Cautious movement, conflict avoidance
• Penalty for disturbing environment
• Cost of discovery and combat high
20. Thief: The Dark Project
• Senses are the focus of gameplay– Ebb and flow of knowledge
– Traverse through “dark” areas, literally
and figuratively.
• Sense concepts similar to Half-Life
21. Requirements
• Wide spectrum of tunable states– Broaden gray zone of safety and danger,
hold the player on edge of one or other
– Can’t polarize quickly to extremes of
“sense”/ “not sensed”, “safe”/ “unsafe”
22. Requirements
• Wide spectrum of tunable states• More AI senses operating more often
on more objects
– Notice player activity, even when player
not present
– Bodies poorly hidden and blood left behind
– A big performance challenge
23. Requirements
• Wide spectrum of tunable states• More AI senses operating more often
on more objects
• Stable and intelligible
– Analog feel, avoid un-fun feedback
– Players and designers understand inputs
and outputs
– Outputs match learned expectations
– Limited number of player-perceivable
inputs, and discrete valued results.
24. Similar to Half-Life
• Viewcone and raycast based vision• Simple hearing system leveraging core
sound system
• Game hooks
– Optimization
– Game mechanics
– Pseudo-sensory data
• Sense gathering decoupled from
decision process
25. Different from Half-Life
Level of Detail
x Player
x Body
x Enemy AI
x Friend AI
Update Frequency
Object oriented with
independently scaled
components
– Relevance to game
design
– Imminence of impact
– State of the AI
26. Different from Half-Life
• Object oriented with independentlyscaled components
• Stateful
• Non-binary outputs
• Allotted more processing time
27. Basic Components
Visibility1
1
Game Object
1
Sense Link
*
Awareness
*
Player
AI
1
1
1
AI Senses
1
A
B A contains/owns B
A
B A refers to be B
A
B A depends on B
A
B B derives from A
1
1
1
*
one-to-one relationship
one-to-many relationship
*
Alertness
Viewcones
Configuration
28. Awareness Range of discrete states Certainty of presence, location, or identity Only qualitative value exposed to other systems
• Awareness– Range of discrete states
– Certainty of presence, location, or identity
– Only qualitative value exposed to other
systems or designer
• Alertness
– Agitation state directly and simply
correlated to awareness
– Feeds back into sensing system
29. Sense Links
• Relation to another entity or positionin space
• Stores all relevant data exposed to
other systems (time, location, line-ofsight, etc.)
• Stores hidden data cached for
optimization and continuity
30. Sense Links
HighAwareness,
First Hand,
LOS
Sight & Sound
High
Awareness,
First Hand,
LOS,
Sight & Sound
High
Awareness,
Second Hand,
Sight & Sound
AI
AI
(shadow)
Dead AI
Player
Low Awareness,
First Hand,
Sight
AI
Origin of heard
player sound
Medium
Awareness,
First Hand,
Sound
31. Sense Links
HighAwareness,
First Hand,
LOS
Sight & Sound
High
Awareness,
First Hand,
LOS,
Sight & Sound
High
Awareness,
Second Hand,
Sight & Sound
AI
AI
(shadow)
Dead AI
Player
Low Awareness,
First Hand,
32. Sense Links
• Akin to memory, knowledge• Transmittable through verbalization
and observation
• Can be manipulated by game logic
and scripts
33. Sense Links
HighAwareness,
First Hand,
LOS
Sight & Sound
High
Awareness,
First Hand,
LOS,
Sight & Sound
High
Awareness,
Second Hand,
Sight & Sound
AI
AI
(shadow)
Dead AI
Player
Low Awareness,
First Hand,
Sight
34. Visibility
• Property independent of any viewer• Lighting
• Movement
• Exposure (size, separation)
• Aggregate of all three
• Frequency and resolution scaled
• Analog
35. Visibility
• Closely tied to game requirements– For example, player lit-ness strongly
biased towards lighting near the floor.
Provides objective perceivable way to
judge present and future safety
36. Visibility
HighAwareness,
Second Hand,
Sight & Sound
AI
Visibility
AI
(shadow)
Dead AI
Player
Low Awareness,
First Hand,
Sight
AI
Origin of heard
player sound
Medium
Awareness,
First Hand,
Sound
37. Viewcones
• Multiple viewcones– Three dimensional
– Ordered
– XY angle & Z angle
– Configurable acuity
– Enabled/disabled based on alertness
– Oriented according to head position
38. Viewcones
• Only first qualifying viewcone inordered set used for calculations
• Presumed to produce constant output
regardless of subject position in cone
39. Example
1B
2
C
3
A
4
5
• Determine viewcone
• Feed object visibility
and cone properties
into “Look”
• Generate discrete
awareness
40. Example
1B
2
C
3
A
4
5
• Properties affected
by owner’s state
(alertness, “mode”)
• Peripheral, direct,
low-light vision
• Acuity variable to any
visibility component
• Enumerated controls
• Cone 5: false vision
41. Pipeline
• Series of components• Each take a limited well defined set of
data, output a yet more limited value
• Independently scalable based on
gameplay
• All layers scalable to extremely low
process or usage
42. Pipeline
• End output is a single discreteawareness value for the object of
interest
• Heuristics are a black box
43. Tuning
• Programmer did most fine tuning– Understanding of black boxes
– Ability to alter black boxs
• Lots of playing and experimenting
• Possible retuning if leveraged systems
change
• Closely tied to higher level behaviors
(search patterns, head movements)
• Designers given simpler controls
44. Pipeline
PositionLighting
M ovement
Exposure
Sound System
Visibility
Sound Queue
Viewcone
Selector
Viewcone
Non-specific
Spatial Events
Look
Listen
Sense Pulse
Receiver
Inter-AI
Communication
Game
M echanics and
Configuration
Ramp Up Delay
Cool-down
Capacitor
Sense Links
Inter-AI Sharing
By Observ ation
45. Vision
PositionLighting
M ovement
Exposure
Visibility
Viewcone
Selector
Game
M echanics and
Configuration
Viewcone
Look
Listen
Sense Pulse
Receiver
46. Sound
• Leverages sophisticated sound systemin Thief
• Sounds tagged with semantic data
• Propagated through 3D space, with
reflection, occlusion, attenuation
• Could carry information packets
between AIs
47. Sound
Sound SystemSound Queue
Non-specific
Spatial Events
Look
Listen
Sense Pulse
Receiver
Inter-AI
Communication
• Sounds generate
awareness pulses
to points in space
or specific objects
• Sound system
conduit for
awareness
pseudo-sounds
48. Sound
HighAwareness,
Second Hand,
Sight & Sound
AI
Sound
AI
(shadow)
Dead AI
Player
Low Awareness,
First Hand,
Sight
AI
Origin of heard
player sound
Medium
Awareness,
First Hand,
Sound
49. Awareness Pulses
LookListen
Sense Pulse
Receiver
Inter-AI
Communication
Game
M echanics and
Configuration
Ramp Up Delay
Cool-down
Capacitor
Sense Links
Inter-AI Sharing
By Observation
50. Awareness Pulses
• For a given object, highest of eithervision or sound taken as awareness
• Data from vision and sound distilled
into a single awareness pulse
51. Awareness Pulses
• If increasing, filter controls upwardrise
– Time delays (reaction time, forgiveness)
– Formulas configured based on outer AI
state
– Once threshold breached, intermediate
levels skipped
52. Awareness Pulses
• If decreasing, capacitor controlsawareness descent
– Formulas configured based on outer AI
state
– All levels used
• Time-limited free knowledge for
objects no longer generating pulses
– Appearance of memory and deduction
53. Pulse to Link
• Results stored in sense links forhigher-level AI to interpret
• Some sense links created
independently
54. Problems
• Takes advantage of…– Single player (i.e., not client/server)
– Software lighting
• Will place demands on other systems
• Can be CPU intensive
– Time not spent in pathing, tactical
analysis, other decision processes
• A tuning commitment
55. Benefits
• Better information served up wellcooked simplifies higher-level decision
code
• A clean location for expressing “preconscious” behavior
• Generate varied and subtle behavior
without adding complexity to core
decision machine
56. Futher Exploration
• Half-Life SDK• Tools on Thief, Thief 2 CDs, and at
www.thief-thecircle.com
57.
Thanks toRaphael Baptista, Steve Bond, Steve
Desilets, Jen Carlson, Brian Jacobson,
David Kalina, Marc Laidlaw, Jay Stelly,
Mark Waks, and Robin Walker
internet