MakarovSuites
English
EnglishDeutschРусскийУкраїнськаFrançaisEspañolItalianoPolski
Contact & licences

Math

Game tree and alpha-beta

A game tree where every block is as tall as its value: a MAX node stands as high as its tallest child, a MIN node as low as its lowest. Minimax looks at every leaf; alpha-beta skips what cannot change the answer, and how much it skips depends on the order of the moves.

Game tree and alpha-beta — Actual application image
Actual application image

What happens

Every block is as tall as its value, so the rule is visible before it is named: a MAX node stands as high as its tallest child, a MIN node as low as its lowest, and the root is the value of the game. Minimax reads all b^d leaves. Alpha-beta reads them in order and stops looking at a node the moment a sibling already seen makes the rest irrelevant - the branches it never enters stay dark. The answer is never changed by this, only the count is, and the count depends on the ORDER of the moves, not on the tree: with the best move first at every node it needs exactly the Knuth-Moore minimum, about the square root of b^d; with the worst move first it sees every leaf - but only to depth 3, because from depth 4 the alpha raised at the root reaches down and prunes even that. What to watch: the pruned branches, the gold path of the principal variation, and the three bars behind - minimax, this search, the minimum.

Equations used in the module
Equations
MAX node: v = max over children;  MIN node: v = min over children;  minimax reads all b^d leaves
alpha-beta: cut the rest of a node's children as soon as alpha >= beta - the answer is the same, the count is not
perfect ordering: N_min = 2·b^(d/2) − 1 for even d,  b^((d+1)/2) + b^((d−1)/2) − 1 for odd d  (Knuth - Moore, 1975)
worst ordering at every node: N = b^d for d <= 3;  from d = 4 the root's alpha reaches the third level and prunes anyway
ordering s in [−1, 1]: a node's children are sorted by exact value when its own hash coin is below |s| - best first for s > 0, worst first for s < 0

Related experiments

Back to catalogue
Huffman coding — Actual application image

Math

Huffman coding

A sorted queue of frequencies becomes a prefix-code tree. Select a symbol to trace its bits; step through each merge.

Knapsack: greedy against the table — Actual application image

Math

Knapsack: greedy against the table

Choose numbered cargo under a mass limit. Compare your selection with greed and the exact solution, open a table cell and trace the optimal set backwards.

Simplex on the plane — Actual application image

Math

Simplex on the plane

The feasible region lies on the table and a plate hangs over it at the height of the objective. The objective is linear, so the plate is flat and tilted, and the best point is literally its highest corner. The simplex climbs the edges to it.