TL;DR
Counterfactual regret minimization (CFR) is an algorithm for games where players cannot see everything, such as poker. It repeatedly plays the game against itself, and at every information set it runs a no-regret learner that asks how much each action would have gained compared with the strategy actually played. In a two-player zero-sum game, the average of the strategies it plays approaches a Nash equilibrium, which is a set of strategies where neither player gains by switching.
Builds on: Information Set, No-Regret Learning, Mixed Strategy · Leads to: Self-Play, Minimax Game
Where it's used
Heads-up limit hold'em. In 2015 a team led by Michael Bowling reported that heads-up limit Texas hold'em, a two-player game with a limit on bet sizes, was essentially solved. The computation used a CFR variant run over the game tree, and the resulting strategy is close to unbeatable: no opponent can expect to win more than a negligible amount against it.
Libratus. In January 2017 an AI named Libratus beat professional players at heads-up no-limit Texas hold'em, a game with unlimited bet sizes and a far larger tree. Its blueprint strategy came from CFR-based self-play on an abstracted version of the game, and it then refined its play during the match.
Pluribus. In 2019 Pluribus beat professional players at six-player no-limit Texas hold'em. CFR was run in a sampled form, where the algorithm updates only part of the tree on each pass, which keeps the cost low enough for a game with more than two players. The guarantees are weaker than in the two-player case, but the method worked well in practice.
How it works
Take one decision in a poker-like game and let the learner see only what it can see. The example freezes the opponent so that the arithmetic is easy to follow. The opponent bets with probability 0.8 (write this as H) and checks with probability 0.2 (write this as T). Player 1 chooses H or T, and it earns +1 when its choice matches the opponent's action and −1 otherwise. Player 1 runs regret matching, which is CFR at a single information set.
- Start with a uniform strategy. Player 1 plays H and T with probability 0.5 each. Check: the two probabilities add to 1.
- Measure each action against the opponent. Against the opponent's 0.8 and 0.2, H earns , and T earns . Check: the two values have the same magnitude and opposite sign, as they should.
- Compute the value of the strategy played. The uniform strategy earns . Check: the average of the two action values, weighted by the strategy, gives 0.
- Record the regret. The regret of an action is its value minus the strategy's value, so H has regret and T has regret . Add these to the running totals, which are now 0.6 for H and −0.6 for T.
- Turn the regrets into a strategy. Keep only the positive running totals. Only H is positive, so the next strategy plays H with probability 1, and T with probability 0. Check: a strategy that puts all its weight on the action with positive regret is valid.
- Repeat with the new strategy. Playing H with probability 1 earns 0.6, so H has regret and T has regret . The running totals are now 0.6 for H and −1.8 for T. The next strategy is again H with probability 1.
- Average the strategies. Over three iterations, the strategies played were (0.5, 0.5), (1, 0) and (1, 0). The average probability of H is . Check: the strategy that matters in the end is the average, not the last one.
flowchart LR A["Current strategy at each information set"] --> B["Play the game against the opponent"] B --> C["Counterfactual value of each action"] C --> D["Add regrets to running totals"] D --> E["Positive totals give the next strategy"] E --> A E --> F["Average of strategies converges to equilibrium"]
The math
Setup
Let be the players, and let be a profile of strategies, one per player. For each information set of player , let be the set of actions available there, and let be the probability of action at . The probability of reaching a history under is , which multiplies the probabilities of every move on the path, including chance moves. Write for the same product with player 's own moves left out, so it counts only the opponent's and chance's contribution.
The counterfactual value of action at information set for player is
where is the expected payoff to player when play goes through and then the action , and both players follow from then on. The value of the information set itself is the strategy-weighted average of its action values, which is an expected value: .
The word "counterfactual" refers to the weight . The value of reaching is computed as if player had done everything it could to reach , and the chance of its own moves is left out.
Step 2 in symbols: action values
With as the opponent's probability of H, the payoff of H is , and the payoff of T is . The factor is the expected payoff of matching minus mismatching, with the probability of each.
Step 4 in symbols: regret
Let be the strategy at iteration . The instantaneous regret of action at is , and the cumulative regret after iterations is
With the numbers above, and , so and .
Step 5 in symbols: regret matching
Let . The next strategy is
Here adds over the actions at , and the case split covers the start, when no action has positive regret.
Step 7 in symbols: the average strategy
The average strategy is
where is the probability that player reaches , weighting each strategy by how often it is actually used. In the frozen-opponent example the information set is at the root, so this weight is 1 at every iteration. The theorem that CFR relies on says that the cumulative regret of each information set grows no faster than the square root of the number of iterations, so the average strategy's distance from equilibrium shrinks as the iterations grow. The result is stated for two-player zero-sum games.
Worked examples
Three actions at one information set have cumulative regrets .
- Keep the positive parts: is already nonnegative.
- Add them: .
- Divide each by 4: the strategy is .
- Check: .
- Now take cumulative regrets for two actions. No action has positive regret, so the denominator is zero.
- Use the fallback: the strategy is .
Interpretation: regret matching puts weight on actions that would have helped in the past, and it falls back to uniform only when nothing would have helped.
Player 1 reaches information set only when chance or the opponent lets it. Suppose the probability of that, , is 0.2. Under the current strategy for actions call and fold, the continuation payoffs when the action is taken at are and .
- Counterfactual value of call: .
- Counterfactual value of fold: .
- Value of the information set: .
- Regret of call: . Regret of fold: .
- Check: if were reached with probability 1, the regrets would be 1 and −1. The 0.2 factor scales them down by exactly 0.2.
Interpretation: an information set that is rarely reached is updated less, because a mistake there costs the player less in expectation. This is what keeps the update correct when the tree is large and reach probabilities vary across it.
A training run for a poker agent records the cumulative regrets at one decision, a strong hand facing a bet: raise 120, call 40, fold −30, measured in chips.
- Keep the positive parts: raise 120, call 40, fold 0.
- Add them: .
- Divide: raise , call , fold .
- Check: .
- Read the result: the algorithm would raise three times in four and call once in four, and would never fold, since fold's regret is negative.
- Report the average strategy from the run, not this current one, when comparing the agent to others.
Interpretation: a mixed strategy at a single decision is a frequency, and the regrets tell the algorithm which frequency it can still improve on.
Try it: if the regret of call rises to 80 while raise stays at 120, what are the new raise and call probabilities? Answer: the positive total is , so raise is and call is .
Common mistakes and tradeoffs
It is tempting to think the current strategy is the one to use. In fact, in a two-player zero-sum game the average of the strategies converges to equilibrium, while the current strategy can oscillate between good and bad plays. The average is the output to report.
It is tempting to think that low regret guarantees an equilibrium in every game. In fact the two-player zero-sum case has the strongest guarantee, and in games with more players or with general payoffs the average strategies approach a weaker equilibrium concept rather than a Nash equilibrium.
It is tempting to think "counterfactual" means the algorithm imagines the opponent behaving differently. In fact it means the player's own reach is left out of the weight, so that a decision is judged by what it would earn if the player had reached the information set.
When to use CFR: when a game has imperfect information, is large enough that enumerating strategies by hand is impossible, and is two-player zero-sum or can be handled by its multi-player variants. When not to use it: when the game is small enough for a linear program, where exact solvers are more precise, or when the task is single-agent learning with a known reward, where policy-gradient methods are usually simpler. Alternatives: linear programming over the sequence form for small games, fictitious play, and policy-gradient methods in reinforcement learning.
History
The regret-matching rule was analysed by Sergiu Hart and Andreu Mas-Colell in 2000, who showed that it drives the empirical frequency of play toward the set of correlated equilibria in general games. Martin Zinkevich, Michael Johanson, Michael Bowling and Carmelo Piccione introduced counterfactual regret minimization in 2007, applying regret matching at every information set of a poker game and proving that the average strategy converges to equilibrium in two-player zero-sum games.
Later variants made the method practical. CFR+ changed the update rule to keep cumulative regrets nonnegative, which sped up convergence in practice. Sampled versions, such as Monte Carlo CFR, update only part of the tree on each pass. CFR+ was behind the 2015 result, and sampled variants were behind the 2017 and 2019 results described above.
Recap
- CFR runs a no-regret learner at every information set, and the regret of each action is its counterfactual value minus the value of the current strategy.
- Regret matching turns positive cumulative regrets into the next strategy, and falls back to uniform when no regret is positive.
- The counterfactual weight leaves out the player's own reach probability, so rarely reached information sets are updated less.
- In two-player zero-sum games the average strategy approaches a Nash equilibrium, so that average is the output.
- Read next: Self-Play for training by playing against copies of oneself, and Minimax Game for the zero-sum structure that makes the guarantee possible.