Game Theory Unit IV
Game Theory Unit IV
GAME THEORY
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. Both players try to win the game.
o maximizing Player (Max): Max is the player seeking to maximize their utility or score using the
Minimax in AI strategy. In most games, Max represents the AI or the player whose turn it is to
make a move. Max aims to make moves that lead to the highest possible outcome using the min
max search in AI.
o Minimizing Player (Min): Min is the player seeking to minimize Max's utility or score. Min
represents the opponent, whether it's another player or the AI-controlled opponent. Min aims to
make moves that lead to the lowest possible outcome for Max.
def minimax(node, depth, maximizingPlayer):
if depth == 0 or node is a terminal node:
return evaluate(node) # Evaluate the leaf node
if maximizingPlayer:
maxEval = -infinity # Start with a very low value
for child in children(node):
eval = minimax(child, depth - 1, False) # Min's turn
maxEval = max(maxEval, eval) # Take the best (max) score
return maxEval
else:
minEval = infinity # Start with a very high value
for child in children(node):
eval = minimax(child, depth - 1, True) # Max's turn
minEval = min(minEval, eval) # Take the worst (min) score
return minEval
o Alpha-beta pruning is a modified version of the minimax algorithm. It is an optimization technique for the
minimax algorithm.
o As we have seen in the minimax search algorithm that the number of game states it has to examine are
exponential in depth of the tree. Since we cannot eliminate the exponent, but we can cut it to half. Hence
there is a technique by which without checking each node of the game tree we can compute the correct
minimax decision, and this technique is called pruning. This involves two threshold parameter Alpha and
beta for future expansion, so it is called alpha-beta pruning. It is also called as Alpha-Beta Algorithm.
o 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.
o The two-parameter can be defined as:
o Alpha: The best (highest-value) choice we have found so far at any point along the path of
Maximizer. The initial value of alpha is -∞.
o Beta: The best (lowest-value) choice we have found so far at any point along the path of Minimizer.
The initial value of beta is +∞.
Let's take an example of two-player search tree to understand the working of Alpha-beta pruning