AI Wiki中文/EN

Self-play: who should the next version train against?

自博弈

Compare training against the latest self, the average of all past selves and an equilibrium mixture of a growing population, using exact exploitability on a weighted rock–paper–scissors game.

On this pageIntuitionMathematics & methodImplementationLimitationsExercisesResearch connections

Beating yesterday’s version is not the same as getting stronger

You want a game-playing program and have no expert opponent. The obvious plan is to make the program play against itself: train version 2 to beat version 1, version 3 to beat version 2, and so on. Each step produces a clear win, so the program seems to keep improving. Now try it on rock–paper–scissors. If version 1 always plays rock, version 2 learns paper, version 3 learns scissors and version 4 learns rock again. Every version beats its predecessor, and the sequence never gets anywhere.

Self-play means generating training opponents from the learner itself: its current policy, earlier snapshots of it, or a population of its past policies. It removes the need for an outside opponent, but it leaves open the central design choice of this article: which of your own past or present selves the next version should train against. The answer decides whether training cycles, slowly converges or quickly finds a robust policy.

The article uses one exactly solvable game, a weighted rock–paper–scissors whose payoffs are our own synthetic choice, and compares three opponent rules: the latest self, the average of all past selves (fictitious play), and an equilibrium mixture of a growing population (double oracle, a special case of policy-space response oracles). For the large-scale search-based system that learns by self-play in board games, see AlphaZero; this article studies the opponent-selection question in isolation.

Measure progress by exploitability, not by beating the last version

Take a two-player zero-sum game with payoff matrix A, where A(i, j) is what a player gains by playing i against j and the opponent loses the same amount. Our game is symmetric: both players have the same actions, and A is skew-symmetric, so the value of the game is 0. For a mixed strategy x (a probability vector over actions), the expected payoff of each pure action against x is the vector Ax, and the best response gain is its largest entry:

e(x)=max⁡i (Ax)i ≥ 0,e(x)=0  ⟺  x is an equilibrium strategy.e(x)=\max_{i}\,(Ax)_i\ \ge\ 0,\qquad e(x)=0\iff x\ \text{is an equilibrium strategy}.

The quantity e(x) is the exploitability of x: how much an opponent who knows x can win per game. Heinrich and Silver measure their poker results the same way, defining the exploitability of a strategy profile as the expected average payoff that a best-response profile achieves against it; for the symmetric profile (x, x) in our game, that average equals e(x). They also note that exploitability 2δ implies at least a δ-Nash equilibrium. Exploitability Winning against the previous version measures something else: a single entry of A, not the worst case over all opponents.

Our weighted game has payoffs A(P, R) = 1, A(S, P) = 1 and A(R, S) = 2: rock beats scissors by 2, the other wins are worth 1. Its unique equilibrium is (1/4, 1/2, 1/4) for rock, paper and scissors. Against it every pure action earns exactly 0, so no deviation helps. Uniform play is not an equilibrium here; that is why we weight the game.

Rule 1: train against the latest self

Iterated best response replaces the current policy with a best response to it:

xk+1∈BR⁡(xk)=arg⁡max⁡y y⊤Axk.x_{k+1}\in\operatorname{BR}(x_k)=\arg\max_{y}\ y^{\top}Ax_k .

Each new policy beats the old one, but in a game with cycles (rock beats scissors beats paper beats rock) a sequence of pure best responses also cycles. Littman makes a related point about learners that keep adapting to their opponent: in principle, such a learner can be led by a devious opponent into learning a poor policy that is then exploited. Exploitable adaptive learners

Rule 2: train against the average of all past selves

Fictitious play, introduced by Brown in 1951 as Heinrich and Silver recount, has each player best-respond to the opponents’ average behaviour so far:

xˉt=1t∑k=1txk,xt+1∈BR⁡(xˉt).\bar x_t=\frac1t\sum_{k=1}^{t}x_k,\qquad x_{t+1}\in\operatorname{BR}(\bar x_t).

The average strategies converge to Nash equilibria in certain classes of games, including two-player zero-sum games and many-player potential games. Fictitious play convergence The claim concerns the average x̄ₜ, not the latest best response, which in our game is always a pure action and therefore always exploitable.

Neural fictitious self-play (NFSP) turns this into a deep RL method for imperfect-information games. Each agent keeps two networks: one trained by off-policy reinforcement learning on recent experience to approximate a best response, and one trained by supervised learning on a reservoir of its own past best-response actions to approximate its average policy. It plays a mixture of the two, controlled by an anticipatory parameter η. NFSP design In Leduc poker, the authors report that NFSP approached a Nash equilibrium while common reinforcement learning methods diverged. NFSP results summary

Rule 3: grow a population and mix it by a meta-solver

Policy-space response oracles (PSRO) generalize these rules. PSRO keeps a set of policies for each player and an empirical payoff table between them. Each epoch, it computes a meta-strategy, a probability distribution over the existing policies, trains a new policy (an “oracle”) as an approximate best response to the opponents’ meta-strategy, adds it to the set, and fills in the new payoff entries by simulation. PSRO algorithm The choice of meta-strategy recovers familiar methods. Writing σ₋ᵢ for the opponent weights over K earlier policies plus the policy currently being trained in the last slot:

IBR: σ−i=(0,…,0,1,0),independent RL: σ−i=(0,…,0,0,1),FP: σ−i=(1K,…,1K,0).\text{IBR: }\sigma_{-i}=(0,\ldots,0,1,0),\qquad \text{independent RL: }\sigma_{-i}=(0,\ldots,0,0,1),\qquad \text{FP: }\sigma_{-i}=\bigl(\tfrac1K,\ldots,\tfrac1K,0\bigr).

With two players and a Nash equilibrium of the current meta-game as the meta-strategy, PSRO becomes the double oracle algorithm. Special cases Double oracle is guaranteed to converge to an equilibrium in two-player games, but in the worst case it may have to add every strategy; Lanctot and colleagues note that rock–paper–scissors is such a case, because its equilibrium uses all actions. Double oracle Their paper also warns that both extremes have problems: fictitious play keeps generating the same best responses, while responding only to an exact meta-equilibrium can overfit to one specific equilibrium in n-player or general-sum games and fail to generalize to parts of the policy space that no equilibrium reaches; they mix in exploration over the policy set as a compromise. Meta-solver trade-off

The motivation is overfitting. Lanctot and colleagues introduce joint-policy correlation matrices that compare policies trained together with policies trained in separate runs, and argue that independent learners can overfit to the specific partners they trained with. Joint-policy correlation Training against a population is a way to make a policy work against more than one partner.

Three opponent rules on one exact game

The program first checks the equilibrium by computing Ax for x = (1/4, 1/2, 1/4), and reports the exploitability of uniform play. It then runs:

  1. latest self for seven rounds, starting from pure rock;
  2. fictitious play for 10,000 rounds, starting from pure rock, with exact fractions and ties broken toward the lowest index (rock, then paper, then scissors); at checkpoints it reports the average strategy, its exploitability, the latest best response and that response’s exploitability;
  3. double oracle: PSRO whose population contains pure strategies and whose meta-solver finds an exact equilibrium of the current meta-game. The small solver enumerates equal-size supports and solves the indifference equations with NumPy; it is meant for tiny non-degenerate games, not as a general solver.

Nothing is learned from samples: every best response is computed exactly from the payoff matrix. In real self-play the best-response step is a reinforcement learning run and contributes its own error.

"""Exact self-play dynamics on a weighted rock-paper-scissors game.

The payoffs are our own synthetic choice; no game engine or learned network is used.
Row payoff A[i][j] for playing i against j; the game is symmetric and zero-sum.
"""
from fractions import Fraction as F
from itertools import combinations
import numpy as np

NAMES = 'RPS'
# Paper beats rock by 1, scissors beat paper by 1, rock beats scissors by 2.
A = [[0, -1, 2], [1, 0, -1], [-2, 1, 0]]


def payoff_vs(x):
    """Expected payoff of each pure action against mixed strategy x."""
    return [sum(A[i][j] * x[j] for j in range(3)) for i in range(3)]


def best_response(x):
    values = payoff_vs(x)
    return values.index(max(values))  # ties go to the lowest index


def exploitability(x):
    """Gain of a best response against x; the game value is 0, so 0 means equilibrium."""
    return max(payoff_vs(x))


def pure(i):
    return [F(int(j == i)) for j in range(3)]


def latest_self(rounds=7):
    """Iterated best response: train only against the most recent policy."""
    current, history = 0, []
    for _ in range(rounds):
        history.append((NAMES[current], str(exploitability(pure(current)))))
        current = best_response(pure(current))
    return history


def fictitious_play(checkpoints=(1, 10, 100, 1000, 10000)):
    """Best-respond to the average of all previous policies (exact fractions)."""
    counts, rows = [1, 0, 0], []
    for t in range(1, max(checkpoints) + 1):
        avg = [F(c, t) for c in counts]
        br = best_response(avg)
        if t in checkpoints:
            rows.append((t, [round(float(p), 4) for p in avg], round(float(exploitability(avg)), 4),
                         NAMES[br], str(exploitability(pure(br)))))
        counts[br] += 1
    return rows


def solve_zero_sum(M):
    """Maximin strategy of a small square zero-sum matrix by support enumeration."""
    M = np.array(M, dtype=float)
    n = M.shape[0]
    best = None
    for k in range(1, n + 1):
        for rows in combinations(range(n), k):
            for cols in combinations(range(n), k):
                sub = M[np.ix_(rows, cols)]
                # Unknowns: k row probabilities and the value v; columns in support pay v.
                lhs = np.vstack([np.hstack([sub.T, -np.ones((k, 1))]),
                                 np.hstack([np.ones((1, k)), np.zeros((1, 1))])])
                rhs = np.concatenate([np.zeros(k), [1.0]])
                try:
                    sol = np.linalg.solve(lhs, rhs)
                except np.linalg.LinAlgError:
                    continue
                x = np.zeros(n)
                x[list(rows)] = sol[:k]
                if (x < -1e-12).any():
                    continue
                v = float((x @ M).min())
                if best is None or v > best[1] + 1e-12:
                    best = (x, v)
    return best


def double_oracle(start=0, rounds=5):
    """PSRO with a Nash meta-solver over pure-strategy populations (double oracle)."""
    population, log = [start], []
    for _ in range(rounds):
        meta = [[A[i][j] for j in population] for i in population]
        x_sub, value = solve_zero_sum(meta)
        mixed = [0.0] * 3
        for weight, i in zip(x_sub, population):
            mixed[i] += float(weight)
        br = best_response(mixed)
        gain = max(payoff_vs(mixed)) + 0.0
        log.append(([NAMES[i] for i in population], [round(p, 4) for p in mixed],
                    round(value, 4) + 0.0, NAMES[br], round(gain, 4) + 0.0))
        if br in population:
            break
        population.append(br)
    return log


if __name__ == '__main__':
    nash = [F(1, 4), F(1, 2), F(1, 4)]
    print('equilibrium (1/4, 1/2, 1/4): payoffs of R, P, S against it =',
          [str(v) for v in payoff_vs(nash)])
    print('uniform (1/3, 1/3, 1/3): exploitability =', str(exploitability([F(1, 3)] * 3)),
          'by', NAMES[best_response([F(1, 3)] * 3)])
    print('latest-self loop (policy, exploitability):', latest_self())
    print('fictitious play (t, average, exploitability of average, latest BR, its exploitability):')
    for row in fictitious_play():
        print(' ', row)
    print('double oracle (population, meta-Nash as full mix, meta value, BR, BR gain):')
    for row in double_oracle():
        print(' ', row)
Inspect the recorded output
equilibrium (1/4, 1/2, 1/4): payoffs of R, P, S against it = ['0', '0', '0']
uniform (1/3, 1/3, 1/3): exploitability = 1/3 by R
latest-self loop (policy, exploitability): [('R', '1'), ('P', '1'), ('S', '2'), ('R', '1'), ('P', '1'), ('S', '2'), ('R', '1')]
fictitious play (t, average, exploitability of average, latest BR, its exploitability):
  (1, [1.0, 0.0, 0.0], 1.0, 'P', '1')
  (10, [0.3, 0.4, 0.3], 0.2, 'R', '1')
  (100, [0.28, 0.51, 0.21], 0.07, 'P', '1')
  (1000, [0.263, 0.484, 0.253], 0.022, 'R', '1')
  (10000, [0.2556, 0.4959, 0.2485], 0.0071, 'P', '1')
double oracle (population, meta-Nash as full mix, meta value, BR, BR gain):
  (['R'], [1.0, 0.0, 0.0], 0.0, 'P', 1.0)
  (['R', 'P'], [0.0, 1.0, 0.0], 0.0, 'S', 1.0)
  (['R', 'P', 'S'], [0.25, 0.5, 0.25], 0.0, 'R', 0.0)

Reading the output

The equilibrium and a tempting wrong answer. Against (1/4, 1/2, 1/4), rock, paper and scissors each earn exactly 0, so no player can gain by deviating. Uniform play has exploitability 1/3: against it rock earns (0 − 1 + 2)/3 = 1/3 because rock’s win is worth twice as much. Treating a weighted cyclic game as plain rock–paper–scissors would leave a third of a point per game on the table.

The latest self cycles forever. Starting from rock, the sequence is rock, paper, scissors, rock, paper, scissors, rock, with exploitabilities 1, 1, 2, 1, 1, 2, 1. Every step “wins” against its predecessor, by 1 point (paper over rock, scissors over paper) or by 2 (rock over scissors), yet the exploitability never falls below 1. Even averaging one full cycle equally produces uniform play, which the first line shows is still exploitable by 1/3.

The average converges; the latest response does not. Under fictitious play, the exploitability of the average strategy is 1.0 after one round, 0.2 after 10, 0.07 after 100, 0.022 after 1,000 and 0.0071 after 10,000, and the average at 10,000 rounds is (0.2556, 0.4959, 0.2485), close to (1/4, 1/2, 1/4). In this run exploitability falls by roughly a factor of three for each tenfold increase in rounds; that is an observation about this game and tie rule, not a general rate. The latest best response at every checkpoint is still a pure action with exploitability 1. If you deploy the most recent fictitious-play policy instead of the average, you get none of the convergence. This is why NFSP trains a separate network to represent the average policy. Average-policy network

A population with an equilibrium meta-solver finishes in three steps. Double oracle starts with only rock; the meta-game’s equilibrium is rock, and the best response is paper, which gains 1. With rock and paper, the meta-equilibrium is pure paper (paper beats rock), and the best response is scissors. With all three actions, the meta-equilibrium is (0.25, 0.5, 0.25), the best response gains 0, and the best response (rock, by the tie rule) is already in the population, so the algorithm stops. As the PSRO paper notes for rock–paper–scissors, the population had to grow to the full strategy set, because the equilibrium uses every action. Full-support worst case

Cost. Fictitious play performs 10,000 exact best-response computations, each a constant amount of work in a three-action game; the support enumeration examines at most 19 small linear systems per meta-game (9 with one action, 9 with two, 1 with three). The program runs in well under a second. In real games the costs are dominated elsewhere: each best response is a full RL run, and PSRO must fill an empirical payoff table by simulation, with one entry per combination of policies (K to the power n for n players with K policies each); the paper notes that this simulation step takes exponential time. Payoff-table size

What the matrix game hides

Our best responses are exact. In real self-play a best response is approximated by reinforcement learning against sampled opponents, so each new policy can be far from a true best response, and the empirical payoff table is estimated from finite simulations. Generalized weakened fictitious play, mentioned by Heinrich and Silver, tolerates approximate best responses and perturbed updates under its own conditions, but those conditions must be checked for a given method. Approximate fictitious play

The convergence result for fictitious play cited here covers two-player zero-sum and potential games. In general-sum games with more players, there may be several equilibria, and an equilibrium may not be what you want to deploy against real opponents. A policy that is unexploitable is not necessarily the one that wins the most against a particular weak or biased opponent; in Littman’s soccer experiment, the Q-learner trained against a random opponent did especially well against that same opponent, completing more games than the other policies and winning nearly all of them. Specialist versus safe policies

Self-play also needs care in games with imperfect information. In perfect-information alternating-move games a deterministic optimal policy exists, which is the setting where systems like MCTS-based self-play operate. In poker-like games, as in rock–paper–scissors, an optimal policy can require randomization, and Heinrich and Silver report that common reinforcement learning methods diverged in Leduc poker where NFSP approached equilibrium. Imperfect information

Finally, the example is a three-action matrix game with synthetic payoffs. It shows the logic of the three opponent rules, not their performance in any published benchmark or commercial product.

Choose the opponent

  1. Your training log shows that every new version beats the previous version in more than 50% of games. Does this show that the program is getting stronger?

    Answer: No. In the latest-self run every version beats its predecessor by 1 or 2 points per game, yet exploitability cycles between 1 and 2 forever. Winning against the previous version measures one matchup. Exploitability, or performance against a fixed and diverse set of opponents, measures robustness.

  2. In the weighted game, compute the exploitability of the strategy (1/2, 1/2, 0), which never plays scissors.

    Answer: Against it, rock earns (0 − 1)/2 = −1/2, paper earns (1 + 0)/2 = 1/2 and scissors earns (−2 + 1)/2 = −1/2. The best response is paper with gain 1/2, so the exploitability is 1/2.

  3. Fictitious play’s average strategy at 10,000 rounds has exploitability 0.0071, but the policy chosen at round 10,000 has exploitability 1. A colleague proposes deploying the latest policy because it was trained most recently. What do you say?

    Answer: The convergence guarantee concerns the average of past best responses, not the latest one. The latest response is a pure action and is maximally exploitable in this game. Deploy the average (or a model trained to imitate it, as NFSP does), not the latest response.

  4. You train agents for a two-team capture-the-flag game in which strategies can counter each other in cycles, and simulations are expensive. Would you use latest-self training, fictitious play or a PSRO-style population with a meta-solver? What would you monitor?

    Answer: Latest-self training risks cycling in a game with counter-strategies. Fictitious play is safer but responds to an ever-growing average and can be slow. A PSRO-style population lets you choose how opponents are mixed and adds a new policy only when it improves on the current mixture, at the cost of estimating a payoff table that grows quickly with population size. Monitor an exploitability estimate (for example a fresh best response trained against the current mixture), performance against held-out opponents from separate runs, and the growth of the payoff table.

From fictitious play to populations

Several threads meet in self-play. Littman’s 1994 paper notes that training two adaptive Q-learners simultaneously lacks a mathematical justification and can lock up, yet that researchers including Tesauro had reported striking success with that approach in practice. Early simultaneous training Heinrich and Silver (first posted in 2016) combine fictitious self-play with deep reinforcement learning, so that both the best response and the average policy are learned from experience rather than computed. NFSP contribution Lanctot and colleagues (NIPS 2017) frame the opponent rule itself as a choice of meta-solver and show that iterated best response, independent RL, fictitious play and double oracle are special cases of one algorithm. Unifying view

When you read a self-play result, find out which opponents were used during training, which policy was deployed (the latest, the average or a mixture), and how strength was measured. Without those three answers, “trained by self-play” does not tell you whether the policy is robust or merely good at beating its own previous versions.

Make a prediction, then check

After 10,000 rounds of fictitious play, which policy is close to equilibrium?

Choose one answer

Learning objectives

  • Measure self-play progress by exploitability rather than win rate against the previous version, and compute exploitability by hand in small matrix games.
  • Compare latest-self training, fictitious play and PSRO-style populations, and explain why deploying the average policy differs from deploying the latest one.

Prerequisites & connections

Explore related knowledge →

References

  1. Deep Reinforcement Learning from Self-Play in Imperfect-Information Games — arXiv v2 scoped reading
    Johannes Heinrich; David Silver · 2016
  2. A Unified Game-Theoretic Approach to Multiagent Reinforcement Learning — arXiv v2 scoped reading
    Marc Lanctot; Vinicius Zambaldi; Audrūnas Gruslys; Angeliki Lazaridou; Karl Tuyls; Julien Pérolat; David Silver; Thore Graepel · 2017
  3. Markov games as a framework for multi-agent reinforcement learning — scoped reading of a course-hosted copy
    Michael L. Littman · 1994

Version1 · Editorial status: Recorded technical checks completed

View technical check record (AI)

Claude · 2026-12-02 · Independent AI check (Claude subagent, not the author); this is not a human or expert review. Ran example.py with system CPython 3.12.4 and again in a fresh venv with numpy==1.26.4; both outputs are byte-identical to example.stdout.txt, and the python blocks are byte-identical in both languages. Re-derived the equilibrium (1/4, 1/2, 1/4), uniform exploitability 1/3, the latest-self exploitabilities 1, 1, 2, the 19-system support-enumeration count, exercise 2 and the claim that e(x) = max_i (Ax)_i is non-negative and zero exactly at equilibrium for a skew-symmetric A; showed that for the symmetric profile (x, x) both players' best-response gains equal e(x), so NFSP's averaged definition gives e(x). Re-read arXiv PDFs via text extraction: NFSP v2 (Brown 1951 fictitious play, convergence in two-player zero-sum and potential games, generalised weakened FP, two networks and reservoir memory, anticipatory parameter, exploitability definition and the 2-delta remark, divergence of common RL in Leduc) and PSRO v2 (double oracle and full-support RPS worst case, IBR/InRL/FP/DO special cases with the meta-strategy vectors, meta-solver trade-off, payoff-tensor simulation cost, JPC). Re-read the Littman 1994 PDF passages on devious opponents, lock-up and the Tesauro/Boyan reports, and Table 3. Compared zh and en via anchors, equations, citation labels, paragraph counts and numeric tokens. Did not read NFSP/PSRO experiment sections or check rendered HTML.

  • For a symmetric zero-sum game (skew-symmetric A), e(x) = max_i (Ax)_i is non-negative and zero exactly at equilibrium; for the symmetric profile (x, x), NFSP's averaged best-response payoff equals e(x).
  • TD-Gammon is not named in the article; Tesauro's success appears only as reported by Littman, with no claim to have read it. The weighted rock-paper-scissors payoffs are labelled synthetic in prose and code.
  • Running in a separate venv with numpy 1.26.4 gives output byte-identical to the recorded output.
  • Found and fixed one computational misstatement: in the latest-self cycle, the rock-over-scissors step wins by 2, not 1.

Source locations checked:

  • Deep Reinforcement Learning from Self-Play in Imperfect-Information Games — arXiv v2 scoped reading · pdftotext pp.1–5. Checked: fictitious play attributed to Brown 1951 and defined as best response to average behaviour (pp.1, 3); convergence of average strategies in two-player zero-sum and potential games (p.3); generalised weakened FP tolerating approximate best responses (p.3); NFSP two networks/two memories, reservoir sampling, anticipatory parameter and mixture policy, Algorithm 1 (pp.3–5); exploitability as expected average best-response payoff and 2δ ⇒ δ-Nash (p.5); Leduc: approached Nash while common RL diverged (abstract/intro). NOT read: result figures/numbers (pp.6+), appendix.
  • A Unified Game-Theoretic Approach to Multiagent Reinforcement Learning — arXiv v2 scoped reading · pdftotext pp.1–6. Checked: independent RL overfitting motivation (p.1), double oracle definition, two-player convergence and RPS full-support worst case (pp.2–3), PSRO Algorithm 1 and special cases IBR (0,…,1,0), InRL (0,…,0,1), FP (1/K,…,1/K,0), DO with Nash meta-solver (p.4), FP/DO overfitting trade-off and γ-exploration (p.4), payoff tensor exponential in |Π| and K^n space (pp.4–5), JPC matrix definition (p.6), NIPS 2017 venue (p.1). NOT read: appendices, JPC values, Leduc results.
  • Markov games as a framework for multi-agent reinforcement learning — scoped reading of a course-hosted copy · Same scoped reading as for multi-agent-rl. Used here for: simultaneous training of two Q-learners not mathematically justified, prone to locking up, yet reported successes citing Tesauro (§6); vulnerability of continually adapting agents to being led into a poor policy and exploited (§7); QR's strong results vs the random opponent (§6); deterministic optimal policies in alternating-move games (§3). Tesauro's own paper was NOT read.

Related topics

No matches. Try a synonym or acronym.

0 results shown

Wrap the whole query in double quotes for a phrase match.