oct27-AIGames - supporting lehigh cse

Game AI versus AI: An Introduction
to AI Game Programming
Héctor Muñoz-Avila
Some Interesting Facts About
the Game Industry
• As of 2004, the game industry is at least as large
(measured in terms of revenue) as the movie
(Hollywood) industry
• As of 2007, the video game sector remains one
of the above-average growth segments of the
U.S. and global entertainment industries
• Video game sales remains strong today. As an
example, sales of the latest World of Warcraft
expansion (November/2010) outpaced previous
expansions
AI vs Game AI
A
C
B
B
C
A
C
A B
C
A B
C
A
B
B
A C
A B C
A
B C
C
B
A
A
B
C
B
A C
A
B C
AI
B
A
C
research
Game AI
as game practitioners
implemented it
We need to understand the
connections and the
misconceptions from both sides
Game AI
Do you know what is attack Kung-Fu style?
http://www.youtube.com/watch?v=q1yId7Ug2Mg
Half-Life: Gordon Freeman’s First
Encounter with the Marines
Do they attack Kung-Fu style?
Half-Life Kung-Fu Attack
http://www.youtube.com/watch?v=dKNGRuXVa4U
•Actually no more
than 2 marines are
attacking at any
time
•The other marines
take cover, move
around etc.
•When one of the
attacking marines
run out of ammo, is
wounded, dies, etc.,
one of the others
take his place
•Some reactions are hard-coded and scenario-dependent
Game AI
• Term refers to the algorithms controlling:
– The computer-controlled units/opponents
– Gaming conditions (e.g., weather)
– Path finding
• Attack Kung-Fu style is an example of game AI for
the computer opponent
• Programming intentional mistakes is also part of
controlling the computer opponent “AI”
Programming “Good” AI Opponent
(according to Lars Liden; Ch. 2; AIWS1)
• Enemies move before firing
• Make mob/enemy visible
• Announce enemy presence by sound or other means
http://www.youtube.com/watch?v=vL8YfqyU4Fo&feature=related
Programming “Good” AI Opponent (II)
(according to Lars Liden; Ch. 2)
•
•
•
•
Have horrible aim (rather than doing less damage)
Miss the first time
Warn the player (e.g., music, sound)
Kung-Fu attacks
Some AI Topics
•Search
Some of which have been applied in
commercial computer games
•Planning
•Game theory
•Machine learning
•Case-based reasoning
•Robotics
•Computer vision
•Neural networks
Using AI in Games
• Path finding for our
units using heuristic
search (1)
Deliberative
Planning of
objectives with
automated
planning
(3)
• What-if analysis to
counter the opponent
using game theory (2)
• Our units avoid
repeating mistakes by
using machine
learning and casebased reasoning (3)
(2)
(1)
Memory Capacity
The Power of Game Computing and Its
Consequences
• Every year, computers are made with more
and more memory
• This makes for bigger and bigger maps in
games
• Much effort must be spent on pathfinding
which could be better utilized elsewhere
• The amount of memory gained goes into the
bigger maps and unfortunately a lot of it must
be spent on navigation
Pathfinding
•Frequently games use a
collection of nodes
(“waypoints”) and edges
connecting those nodes
•Algorithms are devised
that find a path through
the waypoints for two
given nodes
•Challenges arise when
there are too many
waypoints
Divide and Conquer
the map
Area Based Path Look Up Tables:
A Hierarchical Example
Game Theory
• Idea: Build a tree describing all possible
gaming moves between two opponents
• Analyze tree looking ahead N moves into
the “horizon” and select best move
• Well understood: Nash equilibrium
• Challenge: game tree can be too large
 Parallelism & heuristics: Deep Blue
 Abstract states: Poki-Poker
• Restrictions: perfect information and
deterministic outcomes
Cutting Off Search
•
When to cutoff minimax expansion?
Fixed depth limit
Iterative deepening until times runs out
•
Potential problem with cutting off search: Horizon
problem
Decision made by opponent is damaging but
cannot be “seen” because of cutoff
•
Solution:
Quiescent: states that are unlikely to exhibit wild
swings in the values of the evaluation functions
Evaluation Function
• Evaluation Function
– Is an estimate of the actual utility
– Typically represented as a linear function:
EF(state) = w1f1(state) + w2f2(state) + … + wnfn(state)
– Example:
Chess
• weight: Piece  Number •Function; state  Number
f1 = #(pawns,w)  #(pawns,b)
(w1) Pawn  1
f2 = #(knight,w)  #(knight,b)
(w2) Knight  3
f3 = #(bishop,w)  #(bishop,b)
(w3) Bishop  3
f4 = #(rook,w)  #(rook,b)
(w4) Rook  5
f5 = #(knight,w)  #(knight,b)
(w5) Queen  9
Example: Horizon Problem
“all things been equal”
White moves,
Who is winning?
Black
Is this consistent with
Evaluation function?
No!
Machine Learning: An Example
We used Unreal Tournament© a team-based FPS
• A number of fixed domination
locations.
• When a team member steps
into one of these locations, the
status of the location changes
to be under the control of
his/her team.
• The team gets a point for
every five seconds that each
domination location remains
under the control of that team.
• The game is won by the first
team that gets a pre-specified
amount of points.
The RETALIATE Algorithm
Uses Reinforcement Learning:
• Agents learn behavior policies through rewards and
punishments
• Policy - Determines what action to take from a given state
• Agent’s goal is to maximize some reward
• Can be shown to converge to optimal policy (sort of
equilibrium)
Before/After Policies
Before
After
AI in Commercial Games
Automated
Planning
Machine
Learning
Reasoning with
Uncertainty
Interested?
• CSE 348 AI Game Programming
• CSE 42 Principles of Computer Game
Design
• CSE 327 AI Theory and Practice
• Research:
Independent Studies (undergraduates): 30+
MS Thesis: 10
PhD Dissertations: 5