0% found this document useful (0 votes)
52 views

Game Playing: Kevin Night and Elaine Rich, Nair B. Chapter 12: PG No 231 - 246

This document discusses game playing and algorithms for game tree search. It introduces minimax search which evaluates game trees by applying a static evaluator to leaf nodes and passing values back up the tree. Alpha-beta pruning is described as a method to reduce the number of nodes evaluated by only considering moves that may occur in gameplay. It works by placing alpha and beta bounds on the values along each path and allowing early cutoffs when a move is proved worse than a previous move. Examples are provided to illustrate minimax, game trees, alpha-beta pruning and how it reduces the search space compared to basic minimax.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
52 views

Game Playing: Kevin Night and Elaine Rich, Nair B. Chapter 12: PG No 231 - 246

This document discusses game playing and algorithms for game tree search. It introduces minimax search which evaluates game trees by applying a static evaluator to leaf nodes and passing values back up the tree. Alpha-beta pruning is described as a method to reduce the number of nodes evaluated by only considering moves that may occur in gameplay. It works by placing alpha and beta bounds on the values along each path and allowing early cutoffs when a move is proved worse than a previous move. Examples are provided to illustrate minimax, game trees, alpha-beta pruning and how it reduces the search space compared to basic minimax.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
You are on page 1/ 32

GAME PLAYING

UNIT III
Kevin Night and Elaine Rich, Nair B.
Chapter 12 : Pg No 231 - 246
Topics
• Overview
• Minimax Search Procedure
• Adding Alpha-beta Cutoffs

CS18601 Unit 3 Game Playing - R


03/29/22 2
Jayabhaduri
Games
• A game consists of a set of two or more players, a set of
moves for the players, and a specification of payoffs
(outcomes) for each combination of strategies.

Randomness can usually be modeled by ”hidden information” - are


called games with imperfect information

CS18601 Unit 3 Game Playing - R


03/29/22 3
Jayabhaduri
Game as Search Problem
• Initial State: board position
and player to move
• Successor Function: returns a
list of legal (move, state) pairs
• Terminal Test: determines
when the game is over
• Utility function: Gives a
numeric value for the
terminal state

CS18601 Unit 3 Game Playing - R


03/29/22 4
Jayabhaduri
Game Trees
• Game trees are used to
represent two-player
games.
• Alternate moves in the
game are represented by
alternate levels in the
tree (plies).
• Nodes in the tree
represent positions.
• Edges between nodes
represent moves.
• Leaf nodes represent
won, lost or drawn
positions.

CS18601 Unit 3 Game Playing


03/29/22 5
- R Jayabhaduri
Game Trees - Structure
A strategy defines a complete plan of action for a given player.

This is an example of a
partial game tree for the
game tic-tac-toe.
Even for this simple game,
the game tree is very large.

CS18601 Unit 3 Game Playing


03/29/22 6
- R Jayabhaduri
Assumptions
• In talking about game playing
systems, we make a number of
assumptions:
– The opponent is rational –
will play to win.
– The game is zero-sum – if
one player wins, the other
loses.
– Usually, the two players
have complete knowledge
of the game.
For games such as poker, this
is clearly not true.

CS18601 Unit 3 Game Playing


03/29/22 7
- R Jayabhaduri
Minimax
• Minimax is a method used to
evaluate game trees.
• A static evaluator is applied to
leaf nodes, and values are
passed back up the tree to
determine the best score the
computer can obtain against a
rational opponent.
• Consider two players, MAX and
MIN. Player MAX is trying to
maximize the score and player
MIN is trying to minimize the
opponent’s score. We assume
that the players are rational.

CS18601 Unit 3 Game Playing


03/29/22 8
- R Jayabhaduri
Minimax algorithm
• The minimax algorithm allows each player to compute their
optimal move on a game tree of alternating MAX and MIN
nodes.

CS18601 Unit 3 Game Playing - R


03/29/22 9
Jayabhaduri
Minimax Example

CS18601 Unit 3 Game Playing - R


03/29/22 10
Jayabhaduri
Minimax – Animated Example
Max 3 6 The computer can
obtain 6 by
choosing the right
Min 6 hand edge from the
5 3 first node.

Max 1 3 6 0 7
5

5 2 1 3 6 2 0 7

CS18601 Unit 3 Game Playing - R


03/29/22 11
Jayabhaduri
Minimax Function

• MINIMAX-VALUE(n) =
– UTILITY(n) if n is a terminal state
– maxs  Successors(n) MINIMAX-VALUE(s) if n is a
MAX node
– mins  Successors(n) MINIMAX-VALUE(s) if n is a
MIN node

CS18601 Unit 3 Game Playing - R


03/29/22 12
Jayabhaduri
Searching Game Trees
• Exhaustively searching a game tree is not usually a
good idea.
• Even for a game as simple as tic-tac-toe there are
over 350,000 nodes in the complete game tree.
• An additional problem is that the computer only gets
to choose every other path through the tree – the
opponent chooses the others.

CS18601 Unit 3 Game Playing - R


03/29/22 13
Jayabhaduri
Alpha-beta Pruning
• Minimax suffers from the problem that the number of game
states it has to examine is exponential in the number of moves.
• Alpha-beta pruning - Based on the idea that if a move is clearly
bad, there is no need to follow the consequences of it
– A method for reducing the number of nodes that need to be evaluated by
only considering nodes that may be reached in game play.
– A method that can often cut off a half the game tree
• Alpha-beta pruning places bounds on the values appearing
anywhere along a path:
– 𝛼: the best (highest) value found so far for MAX
– 𝛽: the best (lowest) value found so far for MIN
– 𝛼 and 𝛽 propagate down the game tree. The value v propagates up the
game tree.

CS18601 Unit 3 Game Playing - R


03/29/22 14
Jayabhaduri
Alpha-beta Pruning (Contd..)

CS18601 Unit 3 Game Playing - R


03/29/22 15
Jayabhaduri
Alpha-beta Pruning Example

CS18601 Unit 3 Game Playing - R


03/29/22 16
Jayabhaduri
α-β pruning example

CS18601 Unit 3 Game Playing - R


03/29/22 17
Jayabhaduri
α-β pruning example
=3

alpha cutoff

CS18601 Unit 3 Game Playing - R


03/29/22 18
Jayabhaduri
α-β pruning example

CS18601 Unit 3 Game Playing - R


03/29/22 19
Jayabhaduri
α-β pruning example

CS18601 Unit 3 Game Playing - R


03/29/22 20
Jayabhaduri
α-β pruning example

CS18601 Unit 3 Game Playing - R


03/29/22 21
Jayabhaduri
Alpha Cutoff
>3 =3

8 10

What happens here? Is there an alpha cutoff?

CS18601 Unit 3 Game Playing - R


03/29/22 22
Jayabhaduri
Beta Cutoff

=4 <4

4 >8

8  cutoff

CS18601 Unit 3 Game Playing - R


03/29/22 23
Jayabhaduri
Example : 2 Alpha-Beta Pruning
http://people.cs.pitt.edu/~litman/courses/cs2
710/lectures/pruningReview.pdf

CS18601 Unit 3 Game Playing - R


03/29/22 24
Jayabhaduri
CS18601 Unit 3 Game Playing - R
03/29/22 25
Jayabhaduri
CS18601 Unit 3 Game Playing - R
03/29/22 26
Jayabhaduri
CS18601 Unit 3 Game Playing - R
03/29/22 27
Jayabhaduri
The α-β algorithm

cutoff

CS18601 Unit 3 Game Playing - R


03/29/22 28
Jayabhaduri
Properties of α-β
• Effects of pruning
– Reduces the search space
– Does not affect final result

CS18601 Unit 3 Game Playing - R


03/29/22 29
Jayabhaduri
The Idea of α-β

CS18601 Unit 3 Game Playing - R


03/29/22 30
Jayabhaduri
The α-β Algorithm

CS18601 Unit 3 Game Playing - R


03/29/22 31
Jayabhaduri
Static Evaluation Functions
• A static evaluator assigns a score to a position:
– High positive = computer is winning
– Zero = even game
– High negative = opponent is winning
• It is most important that a static evaluator will
give a better score to a better position – the actual
values are not so important.

CS18601 Unit 3 Game Playing - R


03/29/22 32
Jayabhaduri

You might also like