Simple Algorithm
Reinforcement Learning · Fixed Point · 30 min

Counterfactual Regret Minimization

Regret decomposition over information sets, CFR+ and Monte Carlo CFR.

CFR made poker an optimization problem. But why does minimizing regret separately at every information set minimize it for the whole game, and why do variants that outran its theory converge a hundred times faster? This lesson proves the regret-matching bound with a quadratic potential, proves CFR's regret decomposition, and follows the algorithm through CFR+, Discounted CFR, Monte Carlo sampling and neural networks, keeping apart what is proved from what is only observed.

What you’ll learn

  • Prove that regret matching has external regret at most Δ∣A∣ T\Delta\sqrt{\abs A\,T}, and that regret matching+ inherits the bound.
  • Prove that a player's overall regret is at most the sum of her positive immediate counterfactual regrets, and derive CFR's O(1/T)O(1/\sqrt T) convergence with its constants.
  • State CFR+, Linear CFR and Discounted CFR precisely, and say what is proved about them and what is only measured.
  • Prove that Monte Carlo CFR's sampled counterfactual values are unbiased, and compare external and outcome sampling.
  • Explain how Deep CFR replaces the regret tables with networks, and identify the open problems about fast and last-iterate convergence.

Regret matching, proved

Start with one decision repeated over time. In round tt a learner plays a mixed strategy σt\sigma^t over a finite action set AA and then sees a utility vector ut∈RAu^t\in\R^A whose entries lie in an interval of length Δ\Delta. The instantaneous regret of action aa is rt(a)=ut(a)−⟨σt,ut⟩r^t(a)=u^t(a)-\langle\sigma^t,u^t\rangle, so ∣rt(a)∣≤Δ\abs{r^t(a)}\le\Delta and ⟨σt,rt⟩=0\langle\sigma^t,r^t\rangle=0. The cumulative regret is RT(a)=∑t≤Trt(a)R^T(a)=\sum_{t\le T}r^t(a), and the external regret is max⁡aRT(a)\max_aR^T(a), the shortfall against the best fixed action in hindsight.

Regret matching (Hart & Mas-Colell, 2000) plays each action in proportion to its positive cumulative regret, σt+1(a)=R+t(a)/∑bR+t(b)\sigma^{t+1}(a)=R^t_+(a)/\sum_bR^t_+(b), or uniformly if no regret is positive. It has no step size. That, and its robustness, are why CFR uses it at every information set.

DerivationProof with a quadratic potential
  1. ⟨R+t, rt+1⟩=(∑bR+t(b))∑aσt+1(a) rt+1(a)=0\big\langle R^t_+,\,r^{t+1}\big\rangle=\Big(\sum_bR^t_+(b)\Big)\sum_a\sigma^{t+1}(a)\,r^{t+1}(a)=0

    The cross term vanishes. The next strategy is proportional to R+tR^t_+, and every strategy has zero expected instantaneous regret against its own round. Hence, when R+t≠0R^t_+\ne0 (and trivially otherwise),

  2. ∥R+t+1∥22≤∥R+t+rt+1∥22=∥R+t∥22+2⟨R+t,rt+1⟩+∥rt+1∥22=∥R+t∥22+∥rt+1∥22\norm{R^{t+1}_+}_2^2\le\norm{R^t_++r^{t+1}}_2^2=\norm{R^t_+}_2^2+2\big\langle R^t_+,r^{t+1}\big\rangle+\norm{r^{t+1}}_2^2=\norm{R^t_+}_2^2+\norm{r^{t+1}}_2^2

    The potential grows by at most the new term. Since Rt+1(a)=Rt(a)+rt+1(a)≤R+t(a)+rt+1(a)R^{t+1}(a)=R^t(a)+r^{t+1}(a)\le R^t_+(a)+r^{t+1}(a), and x≤yx\le y implies x+2≤y2x_+^2\le y^2, summing over actions gives

  3. ∥R+T∥22≤T∣A∣Δ2⟹max⁡aRT(a)≤max⁡aR+T(a)≤∥R+T∥2≤Δ∣A∣ T\norm{R^T_+}_2^2\le T\abs A\Delta^2\qquad\Longrightarrow\qquad\max_aR^T(a)\le\max_aR^T_+(a)\le\norm{R^T_+}_2\le\Delta\sqrt{\abs A\,T}

    Induct. Each ∥rt∥22≤∣A∣Δ2\norm{r^t}_2^2\le\abs A\Delta^2 and R0=0R^0=0, so after TT rounds, and the largest positive entry is at most the Euclidean norm:

  4. max⁡aRT(a)≤max⁡aQT(a)≤∥QT∥2≤Δ∣A∣ T■\max_aR^T(a)\le\max_aQ^T(a)\le\norm{Q^T}_2\le\Delta\sqrt{\abs A\,T}\qquad\blacksquare

    Regret matching+. The same three steps apply to QtQ^t, because σt+1∝Qt\sigma^{t+1}\propto Q^t and flooring only lowers norms. Flooring also only raises regrets: by induction Qt(a)≥Qt−1(a)+rt(a)≥Rt(a)Q^t(a)\ge Q^{t-1}(a)+r^t(a)\ge R^t(a). So the true regret is dominated by QTQ^T:

The first step is Blackwell's (1956) approachability condition in disguise: the vector of cumulative regrets must approach the nonpositive orthant, and regret matching picks the strategy that makes the expected next increment orthogonal to the current distance from it. Compared with Hedge, the bound pays ∣A∣\sqrt{\abs A} instead of log⁡∣A∣\sqrt{\log\abs A}, but needs no learning rate. Farina, Kroer & Sandholm (2021) made the connection exact: regret matching is follow-the-regularized-leader, and regret matching+ is online mirror descent, both on the nonnegative orthant with a squared Euclidean regularizer; adding a prediction of the next utility gives predictive regret matching+, often faster still. Hart and Mas-Colell's conditional version, which tracks the regret of swapping each action for another, drives play to correlated equilibria (Learning Dynamics in Games); CFR uses the unconditional one.

Check your understanding

Regret matching starts with zero regrets and plays uniformly over three actions. Round 1's utilities are u1=(1,0,0.5)u^1=(1,0,0.5). What does it play in round 2?

  1. (13,13,13)(\tfrac13,\tfrac13,\tfrac13)
  2. (23,0,13)(\tfrac23,0,\tfrac13)
  3. (1,0,0)(1,0,0)
  4. (0.5,0,0.5)(0.5,0,0.5)
Show the answer

C. (1,0,0)(1,0,0)

Uniform play earned ⟨σ1,u1⟩=0.5\langle\sigma^1,u^1\rangle=0.5, so the regrets are r1=(0.5,−0.5,0)r^1=(0.5,-0.5,0) and only the first action has positive regret: regret matching puts all its weight there. It can jump to a pure strategy after one round, unlike Hedge, which moves by a factor eηΔe^{\eta\Delta} at most. The jumps are harmless for the regret bound, and the time average is what converges in games.

The regret decomposition

Now let player ii face a sequence of opponent strategies in an extensive-form game with perfect recall. Her overall regret compares her play with the best fixed strategy for the whole game, RiT=max⁡σi′∑t≤T[ui(σi′,σ−it)−ui(σt)]R^T_i=\max_{\sigma_i'}\sum_{t\le T}\big[u_i(\sigma_i',\sigma^t_{-i})-u_i(\sigma^t)\big]. Her immediate counterfactual regret at an information set II allows a deviation only there, measured in counterfactual values:

RimmT(I)=max⁡a∈A(I)∑t≤T[vi(σt,I,a)−vi(σt,I)].R^T_{\text{imm}}(I)=\max_{a\in A(I)}\sum_{t\le T}\big[v_i(\sigma^t,I,a)-v_i(\sigma^t,I)\big].

CFR minimizes the second kind separately everywhere. The theorem says this is enough. (Zinkevich et al. state it with regrets divided by TT; it is the same statement.)

DerivationProof by induction from the leaves
  1. RiT ≤ ∑I first(RfullT(I))+R^T_i\ \le\ \sum_{I\ \text{first}}\big(R^T_{\text{full}}(I)\big)_+

    Full regret of a subtree. For I∈IiI\in\mathcal I_i let D(I)D(I) be II together with all of ii's information sets that can follow it, and let RfullT(I)R^T_{\text{full}}(I) be the largest gain in ∑tvi(⋅,I)\sum_tv_i(\cdot,I) from changing ii's strategy on D(I)D(I) only. At ii's first information sets these subtrees are disjoint and cover all her decisions, and ui(σ)u_i(\sigma) is the sum of their counterfactual values plus payoffs she cannot affect, so

  2. vi(σI→a,I)=viterm(σ,I,a)+∑I′∈Succ(I,a)vi(σ,I′)v_i(\sigma_{I\to a},I)=v_i^{\text{term}}(\sigma,I,a)+\sum_{I'\in\mathrm{Succ}(I,a)}v_i(\sigma,I')

    Perfect recall splits the value. Every history in a successor I′∈Succ(I,a)I'\in\mathrm{Succ}(I,a) passes through II and action aa, so its opponent-and-chance reach extends that of its prefix in II, while σI→a\sigma_{I\to a} sets ii's own probability of aa to 1. Hence, with vtermv^{\text{term}} collecting terminals reached before ii acts again,

  3. RfullT(I) ≤ RimmT(I)+∑I′∈Succ(I)(RfullT(I′))+R^T_{\text{full}}(I)\ \le\ R^T_{\text{imm}}(I)+\sum_{I'\in\mathrm{Succ}(I)}\big(R^T_{\text{full}}(I')\big)_+

    One level. Take any deviation on D(I)D(I) and write its distribution at II as σ′(I)\sigma'(I). By the split, its total value is the σ′(I)\sigma'(I)-average over aa of the terminal term plus the successors' values under the deviation; each successor's value exceeds its value under σt\sigma^t by at most RfullT(I′)R^T_{\text{full}}(I'), and the average over aa is at most the best single aa. Subtracting ∑tvi(σt,I)\sum_tv_i(\sigma^t,I):

  4. RiT ≤ ∑I first(RfullT(I))+ ≤ ∑I∈Ii(RimmT(I))+■R^T_i\ \le\ \sum_{I\ \text{first}}\big(R^T_{\text{full}}(I)\big)_+\ \le\ \sum_{I\in\mathcal I_i}\big(R^T_{\text{imm}}(I)\big)_+\qquad\blacksquare

    Unroll. With (x+y)+≤x++y+(x+y)_+\le x_++y_+, apply the last line from the deepest information sets upward (where RfullT=RimmTR^T_{\text{full}}=R^T_{\text{imm}}). Perfect recall makes ii's information sets a forest, so each appears exactly once, and the first step gives the theorem.

The proof uses perfect recall twice, to split values cleanly and to make the information sets a forest, and the counterfactual weighting once, to let ii's own reach factor out of every comparison. Without perfect recall the decomposition fails in general, which matters because the card abstractions of poker programs often forget information on purpose. The zero-sum assumption enters only at the end, through the argument of Adversarial Bandits & EXP3 that turns two players' regret bounds into an exploitability bound for the average profile.

Predict before you look

For Kuhn poker the theorem gives e(σˉT)≤4⋅12⋅2/Te(\bar\sigma^T)\le4\cdot12\cdot\sqrt2/\sqrt T. How many iterations does it require to guarantee exploitability at most 0.1? (Vanilla CFR actually gets there in 35.)

Show the answer

460000

T≥482/0.1≈678.8\sqrt T\ge48\sqrt2/0.1\approx678.8, so T≥460,800T\ge460{,}800, against 35 iterations in practice. The worst case is real for some games and opponents, but poker-like games are far kinder, and the gap is one reason practitioners trust measurements over bounds when they choose among CFR variants.

CFR+, Linear and Discounted CFR

CFR+ (Tammelin, 2014; Tammelin, Burch, Johanson & Bowling, 2015) changes three things. Regret matching+ floors cumulative regrets at zero after every iteration, so an action that becomes good is played at once instead of first repaying the negative regret it piled up while it was bad. Alternating updates let player 1 update, then player 2 respond to player 1's new strategy. Linear averaging gives iteration tt weight tt in the average strategy, discounting the poor early iterates.

The theory arrived late and needed repair. Tammelin's report gave no proof; Tammelin et al. proved that regret matching+ has the same regret bound as regret matching and claimed an O(1/T)O(1/\sqrt T) bound for CFR+. Farina, Kroer & Sandholm (2019) found that the argument did not handle alternating updates: with alternation, small regrets no longer imply low exploitability, and they gave a sequence of alternating updates with zero regret for both players but high exploitability (0.5 in the restatement by Burch, Moravčík & Schmid).

In practice CFR+ behaves as if it converged nearly like 1/T1/T. Bowling et al. (2015) ran it on all of heads-up limit hold'em and, unusually, kept the current strategy: the average they had also computed was measured to be more exploitable and was discarded. Neither the speed nor the good behavior of the current strategy has a general explanation.

Discounted CFR (Brown & Sandholm, 2019) generalizes the reweighting. On iteration tt it multiplies positive cumulative regrets by tα/(tα+1)t^\alpha/(t^\alpha+1), negative ones by tβ/(tβ+1)t^\beta/(t^\beta+1), and the accumulated average strategy by (t/(t+1))γ\big(t/(t+1)\big)^\gamma. Taking α=∞\alpha=\infty and β=−∞\beta=-\infty recovers regret matching+; α=β=γ=1\alpha=\beta=\gamma=1 is Linear CFR, which weights both regrets and average by tt. With (α,β,γ)=(32,0,2)(\alpha,\beta,\gamma)=(\tfrac32,0,2), DCFR matched or beat CFR+ on every game the authors tried, usually by a factor of 2 to 3, with an O(1/T)O(1/\sqrt T) guarantee. Linear CFR was strongest in no-limit subgames whose early iterations make large mistakes, but worse than CFR+ asymptotically. Pluribus's blueprint used Linear CFR with sampling.

Sampling: Monte Carlo CFR

Every CFR iteration walks the whole tree, impossible for large games. Monte Carlo CFR (MCCFR; Lanctot, Waugh, Zinkevich & Bowling, 2009) covers the terminal histories ZZ by blocks Q1,…,QmQ_1,\dots,Q_m, samples one block per iteration with probability qjq_j, and updates regrets from that block alone. Let q(z)=∑j: z∈Qjqj>0q(z)=\sum_{j:\,z\in Q_j}q_j>0 be the probability that zz lies in the sampled block.

DerivationSampled counterfactual values are unbiased (Lanctot et al., 2009, Lemma 1)
  1. v~i(σ,I∣j)=∑h∈I ∑z∈Qj: h⊑z1q(z) π−iσ(h) πσ(h,z) ui(z)\tilde v_i(\sigma,I\mid j)=\sum_{h\in I}\ \sum_{z\in Q_j:\ h\sqsubseteq z}\frac{1}{q(z)}\,\pi^\sigma_{-i}(h)\,\pi^\sigma(h,z)\,u_i(z)

    Reweight each sampled terminal history by the inverse of its probability of being sampled:

  2. Ej[v~i(σ,I∣j)]=∑h∈I ∑z⊒hq(z) 1q(z) π−iσ(h) πσ(h,z) ui(z)=vi(σ,I)\E_j\big[\tilde v_i(\sigma,I\mid j)\big]=\sum_{h\in I}\ \sum_{z\sqsupseteq h}q(z)\,\frac{1}{q(z)}\,\pi^\sigma_{-i}(h)\,\pi^\sigma(h,z)\,u_i(z)=v_i(\sigma,I)

    Average over the block drawn. Each zz is included with total probability q(z)q(z), which cancels its weight:

  3. So sampled regrets are unbiased estimates of the true ones, and regret matching on them still has vanishing regret, with high probability, at a price that grows with the estimates' range. Gibson et al. (2012) show the same for any bounded unbiased estimator, with a bound that grows with its variance.

SchemeWhat one iteration samplesCost and guarantee
Chance samplingone outcome of every chance node (in poker, one deal)Full traversal of the players' actions for that deal
External samplingthe opponent's and chance's actions; the traverser's actions are all exploredq(z)=π−iσ(z)q(z)=\pi^\sigma_{-i}(z), so the opponent's reach cancels. With probability 1−p1-p, average regret ≤(1+2/p) ΔMi∣A∣/T\le(1+\sqrt{2/p})\,\Delta M_i\sqrt{\abs A}/\sqrt T, where ∣Ii∣≤Mi≤∣Ii∣\sqrt{\abs{\mathcal I_i}}\le M_i\le\abs{\mathcal I_i}
Outcome samplinga single terminal history, from a sampling profile that mixes in explorationCheapest per iteration and usable from sampled play alone, but weights 1/q(z)1/q(z) can be huge; the bound gains a factor 1/δ1/\delta when q(z)≥δq(z)\ge\delta
External sampling is the usual default for self-play with a simulator. Outcome sampling is what makes regret minimization possible from trajectories, as in online play; baselines that act as control variates cut its variance by an order of magnitude or more (VR-MCCFR; Schmid et al., 2019).

Deep CFR, and what is still open

Tables and abstractions can be replaced by function approximation. Deep CFR (Brown, Lerer, Gross & Sandholm, 2019) keeps, for each player, a network V(I,a∣θp)V(I,a\mid\theta_p) that predicts the (scaled) cumulative regrets, called advantages, and plays regret matching on its outputs. Each iteration runs external-sampling traversals, stores the sampled regrets in a reservoir-sampled memory, and retrains the network from scratch on the whole memory with weight tt on iteration tt, which makes it Linear CFR in function space. A second network, trained on stored strategies, represents the average strategy. The authors call it the first non-tabular CFR variant to succeed in large games: in flop hold'em its exploitability was 37 mbb/g against 47 for NFSP (neural fictitious self-play), and in heads-up limit hold'em it lost by only 11±211\pm2 mbb/g to a strategy from an abstraction with 3.3×1083.3\times10^8 buckets.

text
DEEP-CFR(T, K):
    M_V[1], M_V[2], M_Pi ← empty reservoir memories
    for t = 1 .. T:
        for p in (1, 2):
            repeat K times:                        # external-sampling traversals
                TRAVERSE(root, p, theta_1, theta_2)
                #  at p's nodes: explore every action, store (I, t, sampled regrets) in M_V[p]
                #  at the opponent's nodes: store (I, t, its strategy) in M_Pi, sample one action
            theta_p ← train V(I, a | theta) from scratch on M_V[p]
                      minimizing  sum over samples of  t · (V(I, a | theta) − regret)^2
    Pi ← train the average-strategy network on M_Pi, weighting samples by t
    return Pi

Strategies at each information set come from regret matching on the network's predicted advantages. Retraining from scratch avoids carrying the previous network's errors into the next one.

Key takeaways

  • Regret matching keeps ∥R+T∥22≤T∣A∣Δ2\norm{R^T_+}_2^2\le T\abs A\Delta^2 because each strategy is orthogonal to its own regret increment, so its external regret is at most Δ∣A∣ T\Delta\sqrt{\abs A\,T}; regret matching+ inherits the bound.
  • With perfect recall, a player's overall regret is at most the sum of her positive immediate counterfactual regrets, so CFR's average profile has exploitability at most Δ(∣I1∣+∣I2∣)∣A∣/T\Delta(\abs{\mathcal I_1}+\abs{\mathcal I_2})\sqrt{\abs A}/\sqrt T in two-player zero-sum games.
  • CFR+ (regret matching+, alternating updates, linear averaging) and Discounted CFR keep an O(1/T)O(1/\sqrt T) guarantee, for CFR+ only after a repaired proof, but run orders of magnitude faster in practice; CFR+'s current strategy often converges too, with no general theorem.
  • Monte Carlo CFR divides sampled payoffs by their sampling probability, which makes sampled counterfactual values unbiased; external sampling suits self-play with a simulator, while outcome sampling learns from single trajectories at the price of variance.
  • Deep CFR replaces the regret tables with networks retrained on reservoir memories, Linear CFR in function space. A theory of the fast variants, last-iterate convergence and guarantees under approximation remain open.

Check yourself

In the interactive lesson these are scored with your confidence, and what you miss comes back for review.

Question 1

In the proof that regret matching has regret O(T)O(\sqrt T), why does the cross term ⟨R+t,rt+1⟩\langle R^t_+,r^{t+1}\rangle vanish?

  1. Because regrets are bounded by Δ\Delta
  2. Because σt+1\sigma^{t+1} is proportional to R+tR^t_+, and every strategy has zero expected instantaneous regret in its own round
  3. Because the utilities are chosen by an oblivious adversary
  4. Because the positive part of a vector is orthogonal to its negative part
Show the answer

B. Because σt+1\sigma^{t+1} is proportional to R+tR^t_+, and every strategy has zero expected instantaneous regret in its own round

∑aσt+1(a)rt+1(a)=0\sum_a\sigma^{t+1}(a)r^{t+1}(a)=0 by the definition of instantaneous regret, and R+tR^t_+ is a positive multiple of σt+1\sigma^{t+1}. This is Blackwell's condition: the strategy is chosen so that, whatever the utilities, the next regret increment is orthogonal to the current excess regret.

Question 2

Which assumption does the regret decomposition RiT≤∑I(RimmT(I))+R^T_i\le\sum_I(R^T_{\text{imm}}(I))_+ need?

  1. That the game is zero-sum
  2. That chance moves are uniform
  3. That every information set has exactly two actions
  4. That player ii has perfect recall
Show the answer

D. That player ii has perfect recall

Perfect recall lets the counterfactual value after an action split into the values of the next information sets, and makes those information sets a forest so that each is counted once. The decomposition holds for any number of players and any payoffs; zero-sum enters only when two regret bounds are turned into an exploitability bound.

Question 3

Monte Carlo CFR updates from a sampled part of the tree. Why does it divide each sampled terminal payoff by q(z)q(z), the probability that zz was sampled?

  1. So that the sampled counterfactual values are unbiased estimates of the true ones
  2. To keep the sampled values between −Δ-\Delta and Δ\Delta
  3. To give rarely sampled histories less influence
  4. To turn regret matching into regret matching+
Show the answer

A. So that the sampled counterfactual values are unbiased estimates of the true ones

Each zz is in the sample with probability q(z)q(z), so weighting it by 1/q(z)1/q(z) makes the expected sampled value equal the full counterfactual value. Unbiasedness is what lets regret matching on noisy regrets still have vanishing regret; the price is variance, largest when q(z)q(z) is small, as in outcome sampling.

Question 4

Which statement about CFR+ is accurate?

  1. It is proved to converge at rate O(1/T)O(1/T)
  2. Its average converges, but its current strategy provably never does
  3. Its proven worst-case rate is CFR's O(1/T)O(1/\sqrt T), yet it is often orders of magnitude faster in practice, and its current strategy often converges too
  4. It needs Monte Carlo sampling to work
Show the answer

C. Its proven worst-case rate is CFR's O(1/T)O(1/\sqrt T), yet it is often orders of magnitude faster in practice, and its current strategy often converges too

The repaired proof (Burch, Moravčík & Schmid, 2019) gives the same order as CFR's bound. The speed is empirical: on Kuhn poker CFR+ is about 240 times less exploitable than CFR after 10,000 iterations, and its current strategy reaches 0.017 where CFR's stays near 0.3 to 0.5. Cepheus played CFR+'s current strategy.

Further reading

  • M. Zinkevich, M. Johanson, M. Bowling & C. Piccione, "Regret minimization in games with incomplete information," Advances in Neural Information Processing Systems 20 (2007).
  • M. Lanctot, K. Waugh, M. Zinkevich & M. Bowling, "Monte Carlo sampling for regret minimization in extensive games," Advances in Neural Information Processing Systems 22 (2009).
  • O. Tammelin, N. Burch, M. Johanson & M. Bowling, "Solving heads-up limit Texas hold'em," Proceedings of the 24th International Joint Conference on Artificial Intelligence (IJCAI), 645–652 (2015).
  • N. Brown & T. Sandholm, "Solving imperfect-information games via discounted regret minimization," Proceedings of the AAAI Conference on Artificial Intelligence 33, 1829–1836 (2019).
  • N. Brown, A. Lerer, S. Gross & T. Sandholm, "Deep counterfactual regret minimization," Proceedings of the 36th International Conference on Machine Learning, PMLR 97, 793–802 (2019).