Professional Documents
Culture Documents
Game Playing in AI
Game Playing in AI
Game Playing in AI
minimax(node, 3, true)
Step 1: The method constructs the whole game-tree and applies the utility
function to obtain utility values for the terminal states in the first step. Let's
assume A is the tree's initial state in the diagram below. Assume that the
maximizer takes the first turn with a worst-case initial value of -infinity, and the
minimizer takes the second turn with a worst-case initial value of +infinity.
Step 2: Next, we'll locate the Maximizer's utilities value, which is -, and
compare each value in the terminal state to the Maximizer's initial value to
determine the upper nodes' values. It will select the best option from all of them.
Step 4: Now it's Maximizer's turn, and it'll choose the maximum value of all
nodes and locate the root node's maximum value. There are only four layers in
this game tree, so we can go to the root node right away, but there will be more
layers in real games.
For node A max(4, -3)= 4
That was the complete workflow of the minimax two player game.
Beta: At every point along the Minimizer route, Beta is the best option or
the lowest value we've identified. The value of beta is initially set to +∞.
Alpha is updated only when it's MAX's time, and Beta can only be updated
when it's MIN's turn.
The MAX player will only update alpha values, whereas the MIN player
will only update beta values.
During the reversal of the tree, node values will be transferred to upper
nodes instead of alpha and beta values.
Step 2
As Max's turn at Node D approaches, the value of α will be decided. When the
value of α is compared to 2, then 3, the value at node D is max (2, 3) = 3.
Hence, the node value is also 3.
Step 3
The algorithm returns to node B, where the value of β will change since this is a
turn of Min. Now β = +∞will be compared to the value of the available
subsequent nodes, i.e., min (∞, 3) = 3, resulting in node B now α = -∞, and β =
3. In the next phase, the algorithm will visit the next successor of Node B, Node
E, and pass the values of α = -∞ and β = 3.
Step 4
Max will take over at node E and change alpha's value. The current existing
value of alpha will be compared to 5, resulting in max (-∞, 5) = 5, and at node
E, where α>=β, the right successor of E will be pruned, and the algorithm will
not traverse it, resulting in the value at node E being 5.
Step 5
We now traverse the tree backward, from node B to node A. At node A, alpha
will be converted to the greatest feasible value of 3, as max (-∞, 3)= 3, and β =
+∞. These two values will now be passed on to Node C, A's right-hand
successor.
At node C, the values and β = +∞ and α =3 will be passed on to node F, and
node F will get the identical values.
Step 6
At node F, the value of α is compared with the left child 0, and max(3,0)= 3. It
is then compared with the right child, which is 1, and max(3,1)= 3.
Step 7
Node F sends the node value 1 to node C. The value of Beta is adjusted at C, α
= 3 and β= +∞, and it is compared to 1, resulting in min (∞, 1) = 1. Now, if α =
3 and β = 1, the condition α>=β is met, the algorithm will prune the next child
of C, which is G, rather than calculating the entire sub-tree G.
Step 8
C now returns the value of 1 to A, with max (3, 1) = 3 being the optimum result
for A. The final game tree is shown here, with nodes that have been calculated
and nodes that have never been computed. As a result, in this case, the ideal
value for the maximizer is 3.