Minmax algorithm and Description
Minmax algorithm and Description
maxTurn, scores,
targetDepth):
if (curDepth == targetDepth):
return scores[nodeIndex]
if (maxTurn):
minimax(curDepth + 1, nodeIndex * 2 + 1,
else:
minimax(curDepth + 1, nodeIndex * 2 + 1,
# Driver code
treeDepth = math.log(len(scores), 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.
o For node D max(-1,- -∞) => max(-1,4)= 4
o For Node E max(2, -∞) => max(2, 6)= 6
o For Node F max(-3, -∞) => max(-3,-5) = -3
o For node G max(0, -∞) = max(0, 7) = 7
Step 3: In the next step, it's a turn for minimizer, so it will compare all
nodes value with +∞, and will find the 3 rd layer node values.