3 - CSE3013 - Adversarial Search
3 - CSE3013 - Adversarial Search
3 - CSE3013 - Adversarial Search
Dr. Pradeep K V
Assistant Professor (Sr.)
School of Computer Science and Engineering
VIT - Chennai
To win the game, these agents engage in competition and attempt to defeat
one another. The adversarial search is a result of such opposing objectives.
Tic-tac-toe, chess, checkers, etc., are such type of games where no luck
factor works, only mind works.
5 Zero-Sum Games :
These games are purely competitive in nature, and one player’s gain is
compensated by other player’s loss.
The net value of gain and loss is zero, and each player will have different
conflicting strategies in these games.
Depending on the game environment and game situation, each player will
either try to maximize the gain or minimize the loss.
The move or strategy depends not only on the game situation and
environment but also on the opponent’s likely strategy and game plan.
This is known as embedded thinking in problem resolution in AI.
Each player backtracks and changes his strategy depends on the progress
of the game, and hence it is also known as backward reasoning in AI.
Chess, Tic-tac-toe is a few of the games played under this rule.
How do it works?
A game can be equated to a type of search in AI, and it will have the
following constituents:
Start of the game: This deals with the initial state of the game and
configurations.
Players: Participants in the game space.
Action: Indicates the moves made by the players in the space.
Result: Outcome of the moves of the players.
Terminal Test: It indicates whether the game is over or not.
Utility: It expresses the final outcome of the game in terms of Loss or
wins or the values.
It 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.
Each layer in the tree has the turns for Maximizer and Minimizer alternatively.
From the initial state, MAX has 9 possible moves as he starts first. MAX
place ’x’ and MIN place ’o’, and both player plays alternatively until we
reach a leaf node where one player has three in a row or all squares are
filled.
Both players will compute each node, minimax, the minimax value which
is the best achievable utility against an optimal adversary.
Suppose both the players are well aware of the tic-tac-toe and playing the
best play. Each player is doing his best to prevent another one from
winning. MIN is acting against Max in the game.
So in the game tree, we have a layer of Max, a layer of MIN, and each
layer is called as Ply. Max place ’x’, then MIN puts ’o’ to prevent Max
from winning, and this game continues until the terminal node.
In this either MIN wins, MAX wins, or it’s a draw.
This game-tree is the whole search space of possibilities that MIN and
MAX are playing tic-tac-toe and taking turns alternately.
1 Step-1: The algorithm generates the entire game-tree and apply the utility
function to get the utility values for the terminal states.
In diagram, let’s take ’A’ is the initial state of the tree. Suppose
Maximizer takes first turn which has worst-case initial value = -∞, and
Minimizer will take next turn which has worst-case initial value = +∞.
2 Step-2: Now, first we find the utilities value for the Maximizer, its initial
value is -∞, so we will compare each value in terminal state with initial
value of Maximizer and determines the higher nodes values. It will find
the maximum among the all.
For node D :
max(-1,-∞) =>
max(-1,4)= 4
For Node E :
max(2, -∞) =>
max(2, 6)= 6
For Node F :
max(-3, -∞) =>
max(-3,-5) = -3
For node G :
max(0, -∞) =>
max(0, 7) = 7
3 Step-3: In the next step, it’s a turn for minimizer, so it will compare all
nodes value with +∞, and will find the 3rd layer node values.
For node B :
min(4,6) = 4
For node C :
min (-3, 7) = -3
4 Step-4: Now it’s a turn for Maximizer, and it will again choose the
maximum of all nodes value and find the maximum value for the root
node. In this game tree, there are only 4 layers, hence we reach
immediately to the root node, but in real games, there will be more than 4
layers.
For node A :
max(4, -3) = 4
α >= β
Step-2 : At Node D, the value of α will be calculated as its turn for Max. The
value of α is compared with firstly 2 and then 3, and the max (2, 3) = 3 will be
the value of α at node D and node value will also 3.
Step-3 : Now algorithm backtrack to node B, where the value of β will change as
this is a turn of Min, Now β = +∞, will compare with the available subsequent
nodes value, i.e. min (∞, 3) = 3, hence at node B now α= -∞, and β= 3.
Here the algorithm traverse the next successor of Node B which is node E, and
the values of α = −∞, and β = 3 will also be passed.
Step-4 : At node E, Max will take its turn, and the value of alpha will change.
The current value of alpha will be compared with 5, so max(−∞, 5) = 5, hence
at node E, α = 5 and β = 3, where α >= β, so the right successor of E will be
pruned, and algorithm will not traverse it, and the value at node E will be 5.
Step-5 : Here, algorithm again backtrack the tree, from node B to node A. At
node A, the value of alpha will be changed the maximum available value is 3 as
max(-∞, 3) = 3, and β= +∞, these two values now passes to right successor of
A which is Node C.
At node C, α = 3 and β = +∞, and the same values will be given to node F.
Step-6 : At node F, again the value of α will be compared with left child which
is 0, and max(3,0)= 3, and then compared with right child which is 1, and
max(3,1)= 3 still α remains 3, but the node value of F will become 1.
Step-8 : C now returns the value of 1 to A here the best value for A is
max (3, 1) = 3. Following is the final game tree which is the showing the
nodes which are computed and nodes which has never computed. Hence
the optimal value for the maximizer is 3 for this example..