Professional Documents
Culture Documents
3
Artificial Intelligence:
Agents, Architecture, and Techniques
Artificial Intelligence
CS 4455
Pathfinding?
Animation selection?
Automatically generated environment?
Best shot at a definition of game AI?
CS 4455
Possible Game AI
Definition
Inclusive view of game AI:
Game AI is anything that contributes to the
perceived intelligence of an entity, regardless of
whats under the hood.
CS 4455
Goals of an
AI Game Programmer
Different than academic or defense industry
1. AI must be intelligent, yet purposely flawed
2. AI must have no unintended weaknesses
3. AI must perform within the constraints
4. AI must be configurable by game designers or
players
5. AI must not keep the game from shipping
CS 4455
Specialization of
Game AI Developer
Strategy Games
Battlefield analysis
Long term planning and strategy
Game Agents
May act as an
Opponent
Ally
Neutral character
Sense-Think-Act Cycle:
Sensing
Sensing:
Enforcing Limitations
Human limitations?
Limitations such as
Not knowing about unexplored areas
Not seeing through walls
Not knowing location or state of player
Sensing:
Human Vision Model for Agents
10
Sensing:
Vision Model
CS 4455
11
Sensing:
Human Hearing Model
CS 4455
12
Sensing:
Modeling Hearing
CS 4455
13
Sensing:
Modeling Hearing Efficiently
Event-based approach
When sound is emitted, it alerts interested agents
CS 4455
14
Sensing:
Communication
15
Sensing:
Reaction Times
16
CS 4455
17
Thinking:
Expert Knowledge
Finite-state machines
Production systems
Decision trees
Logical inference
18
Thinking:
Search
CS 4455
19
Thinking:
Machine Learning
20
Thinking:
Flip-Flopping Decisions
CS 4455
21
Sense-Think-Act Cycle:
Acting
Change locations
Pick up object
Play animation
Play sound effect
Converse with player
Fire weapon
CS 4455
22
Acting:
Showing Intelligence
CS 4455
23
CS 4455
24
Learning
CS 4455
25
Remembering
For example
Where was the player last seen?
What weapon did the player have?
Where did I last see a health pack?
26
Remembering
within the World
27
CS 4455
28
Agent Cheating
Sometimes necessary
For highest difficultly levels
For CPU computation reasons
For development time reasons
29
Set of states
A starting state
An input vocabulary
A transition function that maps inputs and the
current state to a next state
CS 4455
30
Finite-State Machine:
In Game Development
Deviate from formal definition
1. States define behaviors (containing code)
Wander, Attack, Flee
4. Leverage randomness
5. Extra state information
For example, health
CS 4455
31
Problems
Explosion of states
Often created with ad hoc structure
CS 4455
32
Finite-State Machine:
UML Diagram
See Enemy
Wander
Attack
No Enemy
N
o
n
em
y
Flee
CS 4455
o
L
e
H
th
l
a
33
Finite-State Machine:
Approaches
Three approaches
Hardcoded (switch statement)
Scripted
Hybrid Approach
CS 4455
34
Finite-State Machine:
Hardcoded FSM
void RunLogic( int * state ) {
switch( state )
{
case 0: //Wander
Wander();
if( SeeEnemy() )
break;
{ *state = 1; }
case 1: //Attack
Attack();
if( LowOnHealth() ) { *state = 2; }
if( NoEnemy() )
{ *state = 0; }
break;
case 2: //Flee
Flee();
if( NoEnemy() )
break;
{ *state = 0; }
}
}
CS 4455
35
Finite-State Machine:
Problems with switch FSM
1. Code is ad hoc
Language doesnt enforce structure
36
Finite-State Machine:
Scripted with alternative language
AgentFSM
{
State( STATE_Wander )
OnUpdate
Execute( Wander )
if( SeeEnemy )
SetState(
OnEvent( AttackedByEnemy )
SetState( Attack )
State( STATE_Attack )
OnEnter
Execute( PrepareWeapon )
OnUpdate
Execute( Attack )
if( LowOnHealth ) SetState(
if( NoEnemy )
SetState(
OnExit
Execute( StoreWeapon )
State( STATE_Flee )
OnUpdate
Execute( Flee )
if( NoEnemy )
SetState(
}
STATE_Attack )
STATE_Flee )
STATE_Wander )
STATE_Wander )
CS 4455
37
Finite-State Machine:
Scripting Advantages
1. Structure enforced
2. Events can be handed as well as polling
3. OnEnter and OnExit concept exists
4. Can be authored by game designers
Easier learning curve than straight C/C++
CS 4455
38
Finite-State Machine:
Scripting Disadvantages
Bytecode interpreter
With good debugging hooks and support
39
Finite-State Machine:
Hybrid Approach
OnEnter, OnExit
Timers
Handle events
Consistent regulated structure
Ability to log history
Modular, flexible, stack-based
Multiple FSMs, Concurrent FSMs
40
Finite-State Machine:
Extensions
OnEnter, OnExit
Timers
Global state, substates
Stack-Based (states or entire FSMs)
Multiple concurrent FSMs
Messaging
CS 4455
41
CS 4455
42
Common AI Techniques:
A* Pathfinding
CS 4455
43
Common AI Techniques:
Command Hierarchy
CS 4455
44
Common AI Techniques:
Dead Reckoning
45
Common AI Techniques:
Emergent Behavior
CS 4455
46
Common AI Techniques:
Flocking
47
Common AI Techniques:
Formations
CS 4455
48
Common AI Techniques:
Influence Mapping
Facilitates decisions
Can identify the front of the battle
Can identify unguarded areas
CS 4455
49
Common AI Techniques:
Level-of-Detail AI
CS 4455
50
Common AI Techniques:
Manager Task Assignment
51
Common AI Techniques:
Obstacle Avoidance
52
Common AI Techniques:
Scripting
53
Common AI Techniques:
Scripting Pros and Cons
Pros
Scripts changed without recompiling game
Designers empowered
Players can tinker with scripts
Cons
More difficult to debug
Nonprogrammers required to program
Time commitment for tools
CS 4455
54
Common AI Techniques:
State Machine
CS 4455
55
Common AI Techniques:
Stack-Based State Machine
CS 4455
56
Common AI Techniques:
Subsumption Architecture
Higher layers
Goal determination and goal seeking
57
Common AI Techniques:
Terrain Analysis
Resources
Choke points
Ambush points
Sniper points
Cover points
CS 4455
58
Common AI Techniques:
Trigger System
59
Promising AI Techniques
CS 4455
60
Promising AI Techniques:
Bayesian Networks
RTS Example
AI can infer existence or nonexistence of player build units
CS 4455
61
Promising AI Techniques:
Blackboard Architecture
62
Promising AI Techniques:
Decision Tree Learning
CS 4455
63
Promising AI Techniques:
Filtered Randomness
64
Promising AI Techniques:
Fuzzy Logic
CS 4455
65
Promising AI Techniques:
Genetic Algorithms
66
Promising AI Techniques:
N-Gram Statistical Prediction
CS 4455
67
Promising AI Techniques:
Neural Networks
CS 4455
68
Promising AI Techniques:
Perceptrons
CS 4455
69
Promising AI Techniques:
Perceptrons (2)
70
Promising AI Techniques:
Planning
71
Promising AI Techniques:
Player Modeling
CS 4455
72
Promising AI Techniques:
Production Systems
Example
Soar used experiment with Quake 2 bots
Upwards of 800 rules for competent opponent
CS 4455
73
Promising AI Techniques:
Reinforcement Learning
74
Promising AI Techniques:
Reputation System
75
Promising AI Techniques:
Smart Terrain
76
Promising AI Techniques:
Speech Recognition
CS 4455
77
Promising AI Techniques:
Text-to-Speech
78
Promising AI Techniques:
Weakness Modification Learning
CS 4455
79