Minimax Algorithm
Minimax: you maximise your score, the opponent minimises it. Recurse to leaves, back up values. Max node takes the max of children. Min node takes the min. Tic-tac-toe: +1 win, −1 loss, 0 draw. The first move is chosen from those backed-up numbers.
Depth explodes. That is why alpha-beta and depth limits exist. Trace a 2-ply tree on paper: three leaves 3, 5, 2 under a min, then a max above — say the backed-up value before coding.
Minimax Algorithm — output — min children: 3 2 / max chooses: 3. Same tree as the diagram.
MAX
/ \
MIN MIN
/ \ / \
3 5 2 9
\ / \ /
3 2
\ /
3Tiny 2-ply trace + backed-up value.