How does expectimax handle dice rolls in a card-game AI, and what breaks when you search sampled hidden hands as if they were visible?
answer
- a third kind of node
- probability-weighted average
- the scale of scores now matters
- sample deals, solve each, vote
- different moves in identical-looking situations
basics
~20 sExpectimax adds chance nodes worth the probability-weighted average of their outcomes. Searching sampled deals as fully visible (determinization) lets the AI pick different moves in situations it cannot tell apart, and it sees no value in hiding or gathering information.
solid answer
~50 sExpectimax extends minimax with **chance nodes** for random events such as a dice roll; a chance node is worth `sum(p_i * value_i)` over its outcomes, while choice nodes still take max or min. Averaging makes the evaluation's **scale** matter, not just its order, and the tree grows by the number of distinct outcomes at every chance layer; pruning needs known bounds on the evaluation. Hidden hands are handled by **determinization**: sample deals consistent with what has been seen, solve each as a perfect-information game, and aggregate the scores. It is simple and often plays well, but it suffers **strategy fusion**: in each sample the solver acts as if it knew the cards, so a line that needs a later blind guess scores as a certain win. It also cannot value hiding or discovering information. Searching over **information sets** fixes the fusion error at higher cost.
go deeper
Recall that expectimax adds chance nodes whose value is the probability-weighted average of their outcomes, alongside the usual max and min nodes.
Compute a chance node's value for a dice roll and explain why the evaluation's scale, not only its ranking, now changes decisions.
Explain determinization, recognise strategy fusion in a concrete line, and say when the error justifies information-set search.
Weigh a cheap determinized opponent that occasionally misplays guesses against a costlier information-set search, given the game's audience and CPU budget.
## Chance nodes and the expectimax value Minimax has two kinds of node: the maximiser's choices and the minimiser's choices. **Expectimax** adds a third, the **chance node**, for events no player controls, such as a dice roll or a card drawn from a shuffled deck. Its value is the **expected value** of its outcomes: ``` value(chance node) = sum over outcomes i of p_i * value(outcome i) ``` Choice nodes still take the maximum or minimum of their children. With two six-sided dice there are 21 distinct outcomes: 15 non-double pairs, each with probability 1/18, and 6 doubles, each with probability 1/36 (15 * 2/36 + 6 * 1/36 = 1). With `b` moves per turn and `n` distinct outcomes per chance node, the search grows as about `(b * n)^d` over `d` turns, so expectimax games are searched far shallower than deterministic ones at the same budget. ## Why the evaluation's scale now matters Minimax only compares values, so any order-preserving rescaling of the evaluation leaves its choices unchanged. Averaging does not have that property. Suppose move P leads to a fair coin-flip between positions worth 0 and 5 (average 2.5), and move Q leads to a position worth 3 for certain. Expectimax prefers Q. Square every score, which keeps their order since all are non-negative: P averages (0 + 25) / 2 = 12.5 and Q is worth 9, so expectimax now prefers P. The evaluation must therefore be proportional to **expected outcome**, such as a win probability, not just a ranking of positions; only a positive linear transformation is safe. ## Pruning at chance nodes Alpha-beta cutoffs need a bound on a node's value before all its children are seen. At a chance node, an unseen outcome could swing the average arbitrarily unless the evaluation is **bounded**. With known limits `[L, U]`, after seeing some outcomes the node's value lies between `sum(p_i * v_i) + p_remaining * L` and `sum(p_i * v_i) + p_remaining * U`, and the node can be cut when that interval falls outside the window. This idea underlies the **Star1** and **Star2** pruning schemes; without bounds, chance nodes are searched in full. ## Hidden information: determinization In a card game the opponent's hand is hidden, so the AI cannot build one game tree. **Determinization** (also called perfect-information Monte Carlo) works around that: 1. Sample a deal of the hidden cards consistent with everything observed, ideally weighted by how likely the opponent's earlier plays make each deal. 2. Solve that deal as a perfect-information game with minimax, expectimax or MCTS. 3. Repeat for many samples and pick the move with the best total or most votes. It is easy to build from existing perfect-information search and plays strongly in many trick-taking games. Its errors are structural: - **Strategy fusion.** In each sample the solver may choose different later moves for deals the AI cannot actually tell apart. If a line ends in a blind 50/50 guess between two cards, every sample "guesses right" and scores a certain win, so the AI may prefer it to a safe line that truly wins 70% of the time. - **No value for information.** In every sample the solver already sees all cards, so a move that reveals the opponent's hand gains nothing, and a move that hides the AI's own hand protects nothing. - **Non-locality.** The opponent's actual choices depend on what they hold; a solver that treats each deal in isolation ignores what those choices reveal unless the sampling weights account for it. More samples do not fix these errors: every sample makes the same assumption. ## Remedies and their costs | Approach | What it fixes | Cost | |---|---|---| | Determinization | baseline | cheap, reuses existing search | | Belief-weighted sampling | partly fixes non-locality by inferring hands from play | needs an opponent model | | Information set MCTS | strategy fusion: one tree over what the AI can observe, a new deal sampled each iteration | slower convergence, more complex bookkeeping | | Equilibrium methods such as counterfactual regret minimisation | bluffing and mixed strategies in poker-like games | heavy offline computation | - Use plain expectimax when everything except dice is visible. - Use determinization as the cheap first version for hidden cards, and measure where it loses. - Move to information-set search when the losses come from guesses and from hiding information.
- Why does adding more sampled deals not cure strategy fusion?Every sample is solved as if the AI could see all cards, so in every sample it takes the right branch of any later guess. Averaging more such samples converges to the value of a player who always guesses right, not to the value of the real position. Only a search that forces one decision per information set, the set of states the AI cannot distinguish, removes the error.
- When can alpha-beta-style pruning be used at expectimax chance nodes?Only when the evaluation has known bounds. After some outcomes are searched, the remaining probability mass can contribute at most its weight times the maximum score and at least its weight times the minimum, giving an interval for the node. If that interval lies outside the alpha-beta window, the remaining outcomes are skipped. Unbounded evaluations make this impossible.
- A chance node takes the worst outcome, like a minimising opponent.
- Any evaluation that ranks positions correctly works for expectimax.
- Alpha-beta pruning works unchanged at expectimax chance nodes.
- Enough sampled deals make determinization exact.
- Determinization values information-gathering moves correctly.