數位遊戲設計
DIGITAL GAMES DESIGN
Week14 21/May/2008 Instructor: I-Hsien Ting
AI for Games
What is Game AI Focusing on the NPC AI Game AI examples Game AI types Techniques FSM (Finite State Machine) Fuzzy Logic
Decision Tree
Genetic Algorithm
Artificial Neural Networks
The 2007 Game AI Award
-Half life 2 (顫慄時空 2)
1. Valve has taken NPC interaction to the next-level
with this game.
2. The combine soldiers are appear very effective at
coordinating to assault the player.
The AI technology behind the squad behaviors has been maturing well since the original Half-Life, even if this episode didn’t show it off as much as previous games. 3. The game features an impressive variety of
characters
including zombies, robotic dogs and mechanical striders,
etc.
Each of them requires a custom AI, but they all tie into the story very well and work together to improve the player’s experience.
AI?? An AI Test of Half-Life
2
How to define Game AI
Pac Man
Game AI? Yes! No!
The definition of game AI
Paths Finding and Collision Detection
sometimes also have been included into game AI
Broad definition of game AI
Deterministic (定性) Weak AI
Narrow definition of game AI
Nondeterministic (非定性) Strong AI
Weak AI and Strong AI
Weak AI
Path finding
A* Path finding
Collision Detection
Finite state machine (FSM;有限狀態機)
If ~then rules
Fuzzy Logic Strong AI
Decision Tree, Neural Network, Genetic Algorithm, Probabilistic Method, Reinforcement Learning…
Behavior Cloning
Artificial Life
Artificial Life
Artificial Life
Genetic Evolution
http://www.generation5.org/jdk/demos/dictyAppl et.html
Reinforcement Learning
Commercial Game AI
What’s Different
Normally more than one opponent: NPC teams Some NPC’s are opponents and others are there
to support the player
Rationality
How rational is it for a weaker NPC to attack a
stronger player head-on
Believability is a major concern
NPC’s should challenge the player, but not be
Visibility
Additional intelligence adds complexity
Only useful if it’s visible to the player
Player should be able to explain AI behavior
Simpler methods are often preferred
Goal: give the impression of intelligent behavior
AI Wish List
AI should be intelligent, but flawed: make the AI as intelligent as possible and then dumb it down.
The AI should have no blatant flaws:
No “golden path” to defeat the AI every time in the
same way
AI Should not look plain dumb or fail miserable in any situation
AI should be efficient
Real-time reactions
AI normally gets no more than 20% of the CPU time
AI should be configurable by game designer or
Dumbing Down
Make NPC less accurate (e.g. in shotting)
NPC with longer reaction times
Engaging the player only one at a time
NPC making themselves more vulnerable by
moving around in exposed areas or changing positions often
Cheating
Cheating is fine for the AI, but don’t get
caught. Often the easier and more efficient solution
Sometimes, the player can be told (e.g. AI will build new units 25% faster)
Initial position of NPCs is pre-designed (e.g. traps, defense positions)
A* Path Finding
Perform heuristic best-first search Heuristic evaluation of node n
Distance from initial state
Estimated distance to goal state
Admissible heuristic