MathsDiscrete Math

Game Theory
calculator.

Find every Nash equilibrium of a two-player game, pure and mixed, from its payoffs.

How it's worked out

A game here has two players who choose at the same time. The row player picks a row and the column player picks a column, and each cell holds two payoffs: the first for the row player, the second for the column player. In a zero-sum game you type only the row payoff, and the column player gets the same amount with the sign flipped.

Von Stengel's survey defines a best response as a strategy that gives the highest expected payoff against what the other player does. A Nash equilibrium is a pair of strategies that are best responses to each other, so neither player gains by changing alone. The tool first marks every cell where both payoffs are best responses: those are the pure equilibria.

A mixed strategy picks each option with some chance. The key rule, Theorem 2.1 in that survey, is that a player only mixes options that pay equally well against the other player's mix. So each player's chances are set by the other player's payoffs. In a 2 by 2 game, with the column player's payoffs e and g in row 1 and h and k in row 2, the row player plays R1 with chance p.

p\displaystyle p=k−he−g−h+k\displaystyle {}= \frac{k - h}{e - g - h + k}
q\displaystyle q=d−ba−b−c+d\displaystyle {}= \frac{d - b}{a - b - c + d}

The second line uses the row player's payoffs a and b in row 1 and c and d in row 2, and gives the chance q that the column player plays C1. For larger games the tool tries every pair of strategy sets of the same size, solves the matching equations, and keeps the answers whose chances are all at least 0 and where no unused strategy pays more.

It also removes dominated strategies. A strategy is strictly dominated when another one pays more against everything the other player might do, so a player who wants the most payoff never uses it. Removing it can make another strategy dominated, so the step repeats until nothing more goes.

Worked examples

Two friends pick a concert in Battle of the Sexes

Both would rather go together than alone, but the row player prefers the first show (2 against 1) and the column player the second. Going to different shows pays 0 to both. There are 2 pure equilibria, (R1, C1) and (R2, C2), plus one mixed.

p\displaystyle p=2−01−0−0+2\displaystyle {}= \frac{2 - 0}{1 - 0 - 0 + 2}=23\displaystyle {}= \frac{2}{3}
q\displaystyle q=1−02−0−0+1\displaystyle {}= \frac{1 - 0}{2 - 0 - 0 + 1}=13\displaystyle {}= \frac{1}{3}

So the row player goes to the first show with chance 23\frac{2}{3}, and the column player with chance 13\frac{1}{3}. Each expects a payoff of 23\frac{2}{3}, less than either pure equilibrium, because they end up at different shows much of the time.

Open this example in the tool

Two suspects face the Prisoner's Dilemma

Payoffs are years lost, so higher is better. Staying quiet (R1, C1) costs each 1 year if both do it, but a suspect who talks while the other stays quiet goes free. R2 strictly dominates R1 for the row player, and C2 strictly dominates C1 for the column player.

Removing the dominated strategies leaves 1 by 1, so the only equilibrium is (R2, C2), paying −2 each. Both would be better off at (R1, C1), but neither can trust the other to stay there.

Open this example in the tool

Rock-Paper-Scissors as a zero-sum game

A win pays 1 and a loss pays −1. Every pure choice can be beaten, so no cell is a best response for both players and there is no pure equilibrium.

The only equilibrium has each player choose each option with chance 13\frac{1}{3}. Against that mix every reply pays the same, 0, so neither player can do better by leaning one way.

Open this example in the tool

Reading your result

An equilibrium is stable, not best. It only says no player gains by switching alone. The Prisoner's Dilemma shows a stable outcome that both players would happily swap for another one.

Several equilibria raise a new question. In the Stag Hunt both (R1, C1) and (R2, C2) are equilibria, and the mixed one has each player choose R1 with chance 12\frac{1}{2}. The calculator cannot say which one the players will reach. That depends on trust, habit or talk before the game.

Maximin is what you can guarantee. The row player's maximin is the best of the worst cases over rows. In a zero-sum game, a mixed equilibrium closes the gap between maximin and minimax. In Matching Pennies maximin is −1 and minimax is 1, while the mixed equilibrium pays 0. That is Theorem 2.3 in the survey.

Only the order and gaps of payoffs matter. Adding the same amount to all of one player's payoffs, or multiplying them by the same positive number, leaves every equilibrium where it was.

Common mistakes

  • Using your own payoffs to set your own mix. Your chances are chosen to make the other player indifferent, so they come from the other player's payoffs.
  • Mixing up the two numbers in a cell. The first is the row player's, the second the column player's. Swapping them swaps whose problem you solve.
  • Removing a weakly dominated strategy as if it were strict. A weakly dominated strategy can still be part of an equilibrium, so only strict dominance is removed here.
  • Expecting real players to mix exactly. The mixed chances describe a balance point. People in a single round may not randomize at all.

Questions people ask

A finite game always has at least one once mixed strategies count. It can have no pure equilibrium, as in Matching Pennies or Rock-Paper-Scissors, and then the equilibrium is mixed. Games with ties can instead have a whole line of equilibria.

Sources