The founding trick of artificial intelligence, and it contains no learning at all: no data, no training, no weights. Minimax simply enumerates every legal future, assumes you will answer as well as possible, and picks the branch whose worst case is best. This is the tip of the iceberg, the Classical AI layer, where intelligence is search plus logic. You are X and move first. Your ceiling is a draw.
your move. you are X.
Every time it is the AI's turn, the program plays out every possible continuation of the game in its head, all the way to the end, on one shared nine-cell array, placing a mark, recursing, then erasing it (backtracking). Leaf positions are scored from the AI's point of view: its own win is +1, yours is −1, a draw is 0. Walking back up the tree, the AI picks the move with the highest score while assuming you pick the move with the lowest, which is the adversarial assumption that gives the algorithm its name. Because tic-tac-toe is tiny the search is exhaustive, so the answer is not an estimate but a proof, and the number of states it visited is the honest cost of certainty. The same idea, with a depth cutoff and a heuristic instead of true leaves, is what beat Kasparov at chess.