3. OVERVIEW OF GAMES
Games are a form of multi-agent environment
What do other agents do and how do they affect
our success?
Cooperative vs. competitive multi-agent
environments .
Competitive multi-agent environments give rise to
adversarial search.
4. OUTLINES
Introduction to game
Optimal decisions in games
Optimal strategies
Tic-tac-toe.
The minimax algorithm.
Optimal decisions in multiplayer games.
5. GAME SEARCH
Game-playing programs developed by AI researchers since the
beginning of the modern AI
– Programs playing chess, checkers, etc (1950s)
• Specifics of the game search:
– Sequences of player’s decisions we control
– Decisions of other player(s) we do not control
• Contingency problem:
– Many possible opponent’s moves must be “covered” by the
solution
– Opponent’s behavior introduces an uncertainty in the game
– We do not know exactly what the response is going to be
• Rational opponent – maximizes it own utility (payoff)
Function.
6. GAMES VS. SEARCH
Search – no adversary
-Solution is (heuristic) method for finding goal
-Heuristics and CSP techniques can find optimal solution
Evaluation function: estimate of cost from start to goal through
given node.
Examples: path planning, scheduling activities
Games – adversary
-Solution is strategy (strategy specifies move for every possible
opponent reply).
-Time limits force an approximate solution to be taken.
Evaluation function: evaluate “goodness” of
game position
Examples: chess, checkers, Othello, backgammon
7. TYPES OF GAME PROBLEMS
Types of game problems
Adversarial games:
win of one player is a loss of the other
– Cooperative games:
players have common interests and utility function
– A spectrum of game problems in between the two
8. TYPES OF GAME PROBLEMS
Fully cooperative games Adversarial
games
we focus on adversarial games only!!
9. OPTIMAL DECISIONS IN
GAMES
• Game problem formulation:
– Initial state: initial board position and identifies the player
to move
– successor function: legal moves a player can make
– Goal (terminal test): determines when the game is over
– Utility (payoff) function: measures the outcome of the
game and its desirability
• Search objective:
– find the sequence of player’s decisions (moves)
maximizing its utility (payoff)
– Consider the opponent’s moves and their utility
10. OPTIMAL STRATEGIES
-Find the contingent strategy for MAX assuming
an infallible MIN opponent.
-Assumption: Both players play optimally !!
Given a game tree, the optimal strategy can be
determined by using the minimax value of each
node:
-MINIMAX-VALUE(n)=
UTILITY(n) If n is a
terminal
maxs successors(n) MINIMAX-VALUE(s) If n is a
max then
11. EXAMPLE OF AN ADVERSARIAL 2 PERSON
GAME:
TIC-TAC-TOE
Player 1 (x) moves
first
win dro
w
los
s
A two player game
where minmax
algorithm is applies
is Tic–Tac-Toe. In
this game in order to
win you must fill a
row,
a column or diagonal
(X or O).
13. Minimax is a decision rule algorithm, which is
represented as a game-tree.
It has applications in decision theory, game theory ,
statistics and philosophy.
Minimax is applied in two player games. The one is
the min and the other is the max player.
By agreement the root of the game-tree represents the
max player.
It is assumed that each player aims to do the best
move for himself and therefore the worst move for his
opponent in order to win the game.
MINIMAX ALGORITHM
14. MINIMAX ALGORITHM
How to deal with the contingency
problem?
• Assuming that the opponent is rational
and always optimizes its behavior
(opposite to us) we consider the best
response. opponent’s
• Then the minimax algorithm
determines the best move
27. MINIMAX ALGORITHM
function MINIMAX-DECISION(state) returns an action
inputs: state, current state in game
vMAX-VALUE(state)
return the action in SUCCESSORS(state) with value v
function MIN-VALUE(state) returns a utility value
if TERMINAL-TEST(state) then return UTILITY(state)
v ∞
for a,s in SUCCESSORS(state) do
v MIN(v,MAX-VALUE(s))
return v
function MAX-VALUE(state) returns a utility value
if TERMINAL-TEST(state) then return UTILITY(state)
v ∞
for a,s in SUCCESSORS(state) do
v MAX(v,MIN-VALUE(s))
return v
28. PROPERTIES OF MINIMAX
Complete? Yes (if tree is finite)
Optimal? Yes (against an optimal opponent)
Time complexity? O(bm)
Space complexity? O(bm) (depth-first
exploration,for algorithm that generates all
successors at once or O(m) for an algorithm that
generates suuccesors one at atime )
For chess, b ≈ 35, m ≈100 for "reasonable"
games
exact solution completely infeasible
29. Minimax advantages:
-Returns an optimal action, assuming perfect
opponent play.
Minimax is the simplest possible (reasonable) game
search algorithm.
-Tic-Tac-Toe player, chances are you either looked
this up on Wikipedia, or
invented it in the process.)
Minimax disadvantages: It's completely infeasible in
practice.
! When the search tree is too large, we need to limit
the search depth and
apply an evaluation function to the cut-off states.