0% found this document useful (0 votes)
28 views25 pages

Game Playing - AI

The document discusses game playing in artificial intelligence, focusing on the MiniMax search procedure and Alpha-Beta pruning as optimization techniques. It outlines the elements of game playing, types of games, and the structure of game trees, emphasizing the importance of efficient search methods due to high branching factors. Additionally, it provides insights into the properties and limitations of the MiniMax algorithm and illustrates how Alpha-Beta pruning enhances its efficiency by eliminating unnecessary branches in the search tree.

Uploaded by

Niraja Sheth
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
28 views25 pages

Game Playing - AI

The document discusses game playing in artificial intelligence, focusing on the MiniMax search procedure and Alpha-Beta pruning as optimization techniques. It outlines the elements of game playing, types of games, and the structure of game trees, emphasizing the importance of efficient search methods due to high branching factors. Additionally, it provides insights into the properties and limitations of the MiniMax algorithm and illustrates how Alpha-Beta pruning enhances its efficiency by eliminating unnecessary branches in the search tree.

Uploaded by

Niraja Sheth
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 25

GAME PLAYING:

Prepared By:
Sushma Prajapati
Assistant Professor
C.K.Pithawala College Of Engineering and Technology , Surat
Email : sushma.prajapati@ckpcet.ac.in
OUTLINE

• Introduction
• MiniMax Search Procedure
• Alpha-Beta Cut-offs
• Refinements
• Iterative deepening
INTRODUCTION

• Game Playing is an important domain of artificial


intelligence. Games don’t require much knowledge;
the only knowledge we need to provide is the rules,
legal moves and the conditions of winning or losing the
game.
• In other way -> Searches in which two or more players
with conflicting goals are trying to explore the same
search space for the solution aka adversarial searches
TYPES OF GAMES IS AI
Deterministic Chance Moves
(follow a strict (factor of chance or
pattern and set of luck.)
rules)
Perfect information Chess, Checkers Backgammon,
(Complete vision of monopoly
board)
Imperfect Battleships, blind, Bridge, poker,
information (not tic-tac-toe scrabble, nuclear war
aware with what's
going on)
ELEMENTS IN GAME PLAYING
• Initial state: It specifies how the game is set up at the start.
• Player(s): It specifies which player has moved in the state space.
• Action(s): It returns the set of legal moves in state space.
• Result(s, a): It is the transition model, which specifies the result
of moves in the state space.
• Terminal-Test(s): Terminal test is true if the game is over, else it is
false at any case. The state where the game ends is called
terminal states.
• Utility(s, p):A utility function gives the final numeric value for a
game that ends in terminal states s for player p. It is also called
payoff function.
GAME TREE
• A strategy defines a
complete plan of action
for a given player.
• A game tree is a tree
where nodes of the tree
are the game states and
Edges of the tree are the
moves by players.
• Game tree involves initial
state, actions function,
and result Function.
TOWARDS GAME PLAYING PROCEDURE
Both players try to win the game. So, both of them try to
make the best move possible at each turn. Searching
techniques like BFS(Breadth First Search) are not accurate
for this as the branching factor is very high, so searching
will take a lot of time. So, we need another search
procedures that improve –
Generate procedure so that only good moves are
generated.
Test procedure so that the best move can be explored
first.
MINIMAX SEARCH PROCEDURE : OVERVIEW

• Heart of almost every computer board game


• Applies to game where
● Players take turns
● Underlying assumption
• Opponent acts rationally
● Have perfect information
• chess,checkers
MINIMAX SEARCH ALGORITHM
• Mini-max algorithm is a recursive or backtracking algorithm which is
used in decision-making and game theory. It provides an optimal move
for the player assuming that opponent is also playing optimally.
• In this algorithm two players play the game, one is called MAX and
other is called MIN.
• Both the players fight it as the opponent player gets the minimum
benefit while they get the maximum benefit.
• Both Players of the game are opponent of each other, where MAX will
select the maximized value and MIN will select the minimized value.
• depth-first search algorithm
• The minimax algorithm proceeds all the way down to the terminal
node of the tree, then backtrack the tree as the recursion.
MINIMAX SEARCH ALGORITHM : EXAMPLE
MINIMAX ALGORITHM : PROPERTIES

Complete- Min-Max algorithm is Complete. It will


definitely find a solution (if exist), in the finite search tree.
Optimal- Min-Max algorithm is optimal if both opponents
are playing optimally.
Time complexity-O(bm), where b is branching factor of the
game-tree, and m is the maximum depth of the tree.
Space Complexity- similar to DFS which is O(bm).
MINIMAX ALGORITHM : LIMITATIONS

The main drawback of the minimax algorithm is that it gets


really slow for complex games such as Chess, go, etc. This
type of games has a huge branching factor(for chess
b=35,m=100), and the player has lots of choices to decide.
This limitation of the minimax algorithm can be improved
from alpha-beta pruning
ALPHA BETA PRUNING

• ‘pruning’ means cutting down branches and leaves.


• Alpha-beta pruning prunus useless branches in
decision trees.
• Alpha-beta pruning is a modified version of the
minimax algorithm. It is an optimization technique for
the minimax algorithm.
• Alpha-beta pruning can be applied at any depth of a
tree, and sometimes it not only prune the tree leaves
but also entire sub-tree.
ALPHA BETA PRUNING : KEY POINTS

• Alpha: Alpha is the best choice or the highest value


that we have found at any instance along the path of
Maximizer. The initial value for alpha is – ∞.
• Beta: Beta is the best choice or the lowest value that
we have found at any instance along the path of
Minimizer. The initial value for alpha is + ∞.
• The condition for Alpha-beta Pruning is that when α >=
β prune the branch.
ALPHA BETA PRUNING : KEY POINTS
• Each node has to keep track of its alpha and beta values.
Alpha can be updated only when it’s MAX’s turn and,
similarly, beta can be updated only when it’s MIN’s chance.
• MAX will update only alpha values and MIN player will
update only beta values.
• The node values will be passed to upper nodes instead of
values of alpha and beta during go into reverse of tree.
• Alpha and Beta values only be passed to child nodes.
ALPHA BETA PRUNING : EXAMPLE
1. We will first start with the initial move. We will
initially define the alpha and beta values as the
worst case i.e. α = -∞ and β= +∞. We will prune the
node only when alpha becomes greater than or
equal to beta.
2.Since the initial value of alpha is less than beta so
we didn’t prune it. Now it’s turn for MAX. So, at
node D, value of alpha will be calculated. The value
of alpha at node D will be max (2, 3). So, value of
alpha at node D will be 3.
3.Now the next move will be on node B and its
turn for MIN now. So, at node B, the value of alpha
beta will be min (3, ∞). So, at node B values will be
alpha= – ∞ and beta will be 3.
ALPHA BETA PRUNING : EXAMPLE
4.Now it’s turn for MAX. So, at node
E we will look for MAX. The current
value of alpha at E is – ∞ and it will
be compared with 5. So, MAX (- ∞,
5) will be 5. So, at node E, alpha = 5,
Beta = 5. Now as we can see that
alpha is greater than beta which is
satisfying the pruning condition so
we can prune the right successor of
node E and algorithm will not be
traversed and the value at node E
will be 5.
ALPHA BETA PRUNING : EXAMPLE
6.In the next step the algorithm again comes
to node A from node B. At node A alpha will
be changed to maximum value as MAX (- ∞,
3). So now the value of alpha and beta at
node A will be (3, + ∞) respectively and will be
transferred to node C. These same values will
be transferred to node F.
7.At node F the value of alpha will be
compared to the left branch which is 0. So,
MAX (0, 3) will be 3 and then compared with
the right child which is 1, and MAX (3,1) = 3
still α remains 3, but the node value of F will
become 1.
ALPHA BETA PRUNING : EXAMPLE
8.Now node F will return the node value
1 to C and will compare to beta value at
C. Now its turn for MIN. So, MIN (+ ∞, 1)
will be 1. Now at node C, α= 3, and β= 1
and alpha is greater than beta which
again satisfies the pruning condition.
So, the next successor of node C i.e. G
will be pruned and the algorithm didn’t
compute the entire subtree G.
Now, C will return the node value to A
and the best value of A will be MAX (1,
3) will be 3.
ALPHA BETA PRUNING : EXAMPLE

The above represented tree


is the final tree which is
showing the nodes which
are computed and the
nodes which are not
computed. So, for this
example the optimal value
of the maximizer will be 3.
REFINEMENTS
REFERENCES

https://www.mygreatlearning.com/blog/alpha-beta-pruni
ng-in-ai/

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy