數位遊戲設計
DIGITAL GAMES DESIGN
Week15 28/May/2008 Instructor: I-Hsien Ting
AI for Games Part II
Finite State Machine
Behavioral Cloning
Fuzzy Logic
Probability
Finite State Machine (有限狀
態機)
Intelligent Agents
Finite State Machine
Decopose an agent’s behavior into easily
manageable chunks (“states”)
Transitions between the states are activated
by environment or agent-internal events
Why FSM??
Quick and simple to implement
Easy to debug
Computationally efficient
Intuitive
Famous Example: Who’s Who of
FSMs
Pac-Man ghost
Evade and Chase states, Evade state same for all
ghosts, Chase state individual to each ghost
Quake
States include FindHealth, SeekCover, RunAway,
Weapons also are implemented as FSMs: Move, TouchObject, Die
FIFA
Strike, Dribble, ChaseBall, MarkPlayer
Warcraft
FSM Implementation
FSM Implementation
Problems of quick and dirty approach
As more state are added, program becomes more
difficult to understand, and debug
Inflexible: difficult to extend beyond original
purpose
Not possible to treat entry into and exit out of
state in a structured manner (e.g. scream when starting an attach)
FSM tend to grow quickly and become too
FSM Example
Ants
http://im.nuk.edu.tw/~iting/course/im_game_200 8a/Ants.rar Food Die Go Home Thirsty 找到毒物 找到食物 找到水 找到毒物 找到毒物 找到巢穴Behavioral Cloning
What’s it all about?
Reconstruction of skill from an operators’ control
(or action) traces by means of machine learning
Examples:
Flying a plane
Operating a crane
Behavioral Cloning
Why?
Control Skills are often acquired through
experience and are sub-cognitive
Thus, it is hard to reconstruct and implement in a
computer program
Behavior Cloning
Behavior Trace
Trace is set of examples of correct control decision Each example consists of a pair
Time delay between state and action to account
for time needed by operator for state recognition and physical action
Behavior Cloning
Machine Learning
Action(Time)=f(State(Time-Delay)) Goal: learn function f from examples
Decision Tree Learning
Decision Tree Learning
Fuzzy Logic
Fuzzy Logic is an extension of classical logic
that is based on the idea of a fuzzy set.
Distance Value At 0.00..0.15 Very Close 0.10..0.35 Close 0.30..0.70 Pretty Far 0.60..0.90 Very Far 0.85..1.00
Fuzzy Logic
Distance Value At 0.00..0.15 Very Close 0.10..0.35 Close 0.30..0.70 Pretty Far 0.60..0.90 Very Far 0.85..1.00Fuzzy Logic in Game
Control
Train, Air Condition, Robot
E.g. Turning Smoothly