Zero-Sum Games
In some strategic interactions, every gain for one player comes at an equal
cost to another. This chapter studies this important special case, showing how
minimax optimisation and linear programming together characterise optimal play
when interests are directly opposed.
Figure 1: Rock, Paper, and Scissors chase one another in a cycle, with no single action
dominant. Such cyclic advantage is characteristic of zero-sum games, where one
player’s gain is exactly the other player’s loss.
Motivating Example ¶ Consider the standard Rock-Paper-Scissors game
The payoff matrix for the row player is:
M = ( 0 − 1 1 1 0 − 1 − 1 1 0 ) M = \begin{pmatrix}
0 & -1 & 1 \\
1 & 0 & -1\\
-1 & 1 & 0
\end{pmatrix} M = ⎝ ⎛ 0 1 − 1 − 1 0 1 1 − 1 0 ⎠ ⎞ We are going to modify the game to reflect the fact that the row player enjoys winning and hates
losing with Paper more than any other action:
M = ( 0 − 1 1 2 0 − 2 − 1 1 0 ) M = \begin{pmatrix}
0 & -1 & 1 \\
2 & 0 & -2\\
-1 & 1 & 0
\end{pmatrix} M = ⎝ ⎛ 0 2 − 1 − 1 0 1 1 − 2 0 ⎠ ⎞ The column player feels equally strongly about Paper-related outcomes.
Is there a way for the row player to choose a strategy that guarantees a
certain minimum expected payoff, regardless of how the column player responds?
Theory ¶ This chapter will consider a specific subset of Normal Form Games .
Definition: Zero Sum Game ¶ A two player normal form game with payoff matrices ( M r , M c ) ∈ R m × n 2 (M_r, M_c) \in {\mathbb{R}^{m\times n}}^2 ( M r , M c ) ∈ R m × n 2
is called zero sum if and only if:
M r + M c = 0 M_r + M_c = 0 M r + M c = 0 In the case of a zero sum game we will use the convention of defining it with:
and implying M c = − M M_c=-M M c = − M .
Definition: the min-max and max-min strategies ¶ Given a zero-sum game defined by a payoff matrix M ∈ R m × n M \in \mathbb{R}^{m \times n} M ∈ R m × n
and a strategy y ∈ R n y \in \mathbb{R}^n y ∈ R n for the column player , the row player
seeks a best response strategy
x ∈ R m x \in \mathbb{R}^m x ∈ R m that maximises their expected payoff:
max x ∈ A 1 x M y T \max_{x \in \mathcal{A}_1} x M y^T x ∈ A 1 max x M y T This corresponds to choosing the rows of M M M that yields the highest expected
value under the strategy y y y , i.e.,
max i ≤ m ( M y T ) i \max_{i \leq m} (M y^T)_i i ≤ m max ( M y T ) i The column player, by selecting y y y , can influence the upper bound v v v of this
maximum. Since the game is zero-sum, the column player will aim to choose y y y
to make this upper bound v v v as small as possible.
Hence,
max x ∈ A 1 x M y T = max i ≤ m ( M y T ) i = min { v ∈ R | M y T ≤ 1 v } \max_{x \in \mathcal{A}_1} x M y^T = \max_{i \leq m} (M y^T)_i =
\min \left\{ v \in \mathbb{R} \;\middle|\; M y^T \leq \mathbb{1} v \right\} x ∈ A 1 max x M y T = i ≤ m max ( M y T ) i = min { v ∈ R ∣ ∣ M y T ≤ 1 v } The min-max strategy y y y for the column player is the solution to the
following optimisation problem (referred to as a linear program ):
min y , v v subject to M y T ≤ 1 v y ∈ A 2 \begin{aligned}
\min_{y, v} \quad & v \\
\text{subject to} \quad & M y^T \leq \mathbb{1} v \\
& y \in \mathcal{A}_2
\end{aligned} y , v min subject to v M y T ≤ 1 v y ∈ A 2 In this formulation, v v v is the min-max value of the game.
The corresponding max-min strategy x x x for the row player solves the
following linear program:
max x , u u subject to x M ≥ 1 u x ∈ A 1 \begin{aligned}
\max_{x, u} \quad & u \\
\text{subject to} \quad & x M \geq \mathbb{1} u \\
& x \in \mathcal{A}_1
\end{aligned} x , u max subject to u x M ≥ 1 u x ∈ A 1 In this case, u u u is the max-min value of the game.
Example: Max-min strategy for modified Rock-Paper-Scissors ¶ For (2) ,
the max-min strategy x x x for the row player satisfies the following linear
program:
max x , u u subject to 2 x 2 − x 3 ≥ u − x 1 + x 3 ≥ u x 1 − 2 x 2 ≥ u x 1 + x 2 + x 3 = 1 x i ≥ 0 for all i ∈ { 1 , 2 , 3 } \begin{aligned}
\max_{x, u} \quad & u \\
\text{subject to} \quad
& 2x_2 - x_3 \geq u \\
& -x_1 + x_3 \geq u \\
& x_1 - 2x_2 \geq u \\
& x_1 + x_2 + x_3 = 1 \\
& x_i \geq 0 \quad \text{for all } i \in \{1, 2, 3\}
\end{aligned} x , u max subject to u 2 x 2 − x 3 ≥ u − x 1 + x 3 ≥ u x 1 − 2 x 2 ≥ u x 1 + x 2 + x 3 = 1 x i ≥ 0 for all i ∈ { 1 , 2 , 3 } Example: Max-min strategy for Matching Pennies ¶ For the matching pennies game with payoff matrix:
M = ( 1 − 1 − 1 1 ) M = \begin{pmatrix}
1 & -1 \\
-1& 1
\end{pmatrix} M = ( 1 − 1 − 1 1 ) the max-min strategy x x x for the row player satisfies the following linear
program:
max x , u u subject to x 1 − x 2 ≥ u − x 1 + x 2 ≥ u x 1 + x 2 = 1 x i ≥ 0 for all i ∈ { 1 , 2 } \begin{aligned}
\max_{x, u} \quad & u \\
\text{subject to} \quad
& x_1 - x_2 \geq u \\
& -x_1 + x_2 \geq u \\
& x_1 + x_2 = 1 \\
& x_i \geq 0 \quad \text{for all } i \in \{1, 2\}
\end{aligned} x , u max subject to u x 1 − x 2 ≥ u − x 1 + x 2 ≥ u x 1 + x 2 = 1 x i ≥ 0 for all i ∈ { 1 , 2 } Given that x 1 + x 2 = 1 x_1 + x_2 = 1 x 1 + x 2 = 1 , this linear program corresponds to:
max x 1 , u u subject to 2 x 1 − 1 ≥ u − 2 x 1 + 1 ≥ u 0 ≤ x 1 ≤ 1 \begin{aligned}
\max_{x_1, u} \quad & u \\
\text{subject to} \quad
& 2x_1 - 1 \geq u \\
& -2x_1 + 1 \geq u \\
& 0 \leq x_1 \leq 1
\end{aligned} x 1 , u max subject to u 2 x 1 − 1 ≥ u − 2 x 1 + 1 ≥ u 0 ≤ x 1 ≤ 1 These constraints can be rewritten as:
x 1 ≥ 1 + u 2 x 1 ≤ 1 − u 2 0 ≤ x 1 ≤ 1 \begin{aligned}
x_1 &\geq \frac{1 + u}{2} \\
x_1 &\leq \frac{1 - u}{2} \\
0 &\leq x_1 \leq 1
\end{aligned} x 1 x 1 0 ≥ 2 1 + u ≤ 2 1 − u ≤ x 1 ≤ 1 This implies:
1 + u 2 ≤ x 1 ≤ 1 − u 2 \frac{1 + u}{2} \leq x_1 \leq \frac{1 - u}{2} 2 1 + u ≤ x 1 ≤ 2 1 − u which leads to:
1 + u 2 ≤ 1 − u 2 ⇒ u ≤ − u \frac{1 + u}{2} \leq \frac{1 - u}{2} \quad \Rightarrow \quad u \leq -u 2 1 + u ≤ 2 1 − u ⇒ u ≤ − u This inequality holds only when u = 0 u = 0 u = 0 . When u = 0 u = 0 u = 0 , the constraints reduce to:
1 2 ≤ x 1 ≤ 1 2 \frac{1}{2} \leq x_1 \leq \frac{1}{2} 2 1 ≤ x 1 ≤ 2 1 yielding the unique solution x 1 = 1 2 x_1 = \frac{1}{2} x 1 = 2 1 .
Thus, the max-min strategy is:
x = ( 1 2 , 1 2 ) x = \left( \frac{1}{2}, \frac{1}{2} \right) x = ( 2 1 , 2 1 ) Theorem: The minimax theorem ¶ The minimax theorem Neumann, 1928 states that if there exists
optimal values of the:
max-min value u u u and the max-min strategy x x x .
min-max value v v v and the min-max strategy y y y .
then u = v u=v u = v .
The proof which uses the
linear program duality theorem is omitted from
this book but can be found in Vanderbei, 2010 .
Note that this answers the question posed at the end of
Motivating Example
through a choice of strategy the row player can ensure they obtain the
value of the game which is equal to the max-min value and the
min-max value.
In the next section we will start to introduce practical tools with which to do
that.
A standard form of the linear program can be written which more readily
will allow us to use Integer Pivoting .
In a zero-sum game , given a row player payoff
matrix M M M with m m m rows and n n n columns, the following linear program yields
the max-min strategy and the value of the game:
min x ∈ R ( m + 1 ) × 1 c x \min_{x \in \mathbb{R}^{(m + 1) \times 1}} \; c x x ∈ R ( m + 1 ) × 1 min c x subject to:
M ub x ≤ b ub M eq x = b eq x i ≥ 0 for i ≤ m \begin{aligned}
M_{\text{ub}} x &\leq b_{\text{ub}} \\
M_{\text{eq}} x &= b_{\text{eq}} \\
x_i &\geq 0 \quad \text{for } i \leq m
\end{aligned} M ub x M eq x x i ≤ b ub = b eq ≥ 0 for i ≤ m The coefficients in this linear program are defined as:
For the modified Rock-Paper-Scissors game ,
the corresponding coefficients are:
c = ( 0 , 0 , 0 , − 1 ) M ub = ( 0 − 2 1 1 1 0 − 1 1 − 1 2 0 1 ) b ub = ( 0 0 0 ) M eq = ( 1 , 1 , 1 , 0 ) b eq = 1 \begin{aligned}
c &= (0, 0, 0, -1) \\[0.5em]
M_{\text{ub}} &=
\begin{pmatrix}
0 & -2 & 1 & 1 \\
1 & 0 & -1 & 1 \\
-1 & 2 & 0 & 1
\end{pmatrix} \\[0.5em]
b_{\text{ub}} &=
\begin{pmatrix}
0 \\
0 \\
0
\end{pmatrix} \\[0.5em]
M_{\text{eq}} &= (1, 1, 1, 0) \\[0.5em]
b_{\text{eq}} &= 1
\end{aligned} c M ub b ub M eq b eq = ( 0 , 0 , 0 , − 1 ) = ⎝ ⎛ 0 1 − 1 − 2 0 2 1 − 1 0 1 1 1 ⎠ ⎞ = ⎝ ⎛ 0 0 0 ⎠ ⎞ = ( 1 , 1 , 1 , 0 ) = 1 Definition: Tableau for Zero-Sum Game ¶ Given a zero-sum game with payoff matrix M ∈ R m × n M\in \mathbb{R}{m\times n} M ∈ R m × n
the standard form linear program :
can be represented by the following initial tableau :
T = ( x 1 … x m v s 1 … s n b ( − M T ) 11 … ( − M T ) 1 m 1 1 … 0 0 ⋮ ⋱ ⋮ 1 0 ⋱ 0 0 ( − M T ) n 1 … ( − M T ) _ n m 1 0 … 1 0 1 … 1 0 0 … 1 1 0 … 0 − 1 0 … 0 0 ) T =
\left(
\begin{array}{ccccccc|c}
x_1 & \dots & x_m & v & s_1 & \dots & s_n & b\\
(-M^T)^{11} & \dots & (-M^T)_{1m} & 1 & 1 & \dots & 0 & 0\\
\vdots & \ddots & \vdots & 1 & 0 & \ddots & 0 & 0\\
(-M^T)_{n1} & \dots & (-M^T)\_{nm} & 1 & 0 & \dots & 1 & 0\\
1 & \dots & 1 & 0 & 0 & \dots & 1 & 1\\
0 & \dots & 0 & -1 & 0 & \dots & 0 & 0
\end{array}
\right) T = ⎝ ⎛ x 1 ( − M T ) 11 ⋮ ( − M T ) n 1 1 0 … … ⋱ … … … x m ( − M T ) 1 m ⋮ ( − M T ) _ nm 1 0 v 1 1 1 0 − 1 s 1 1 0 0 0 0 … … ⋱ … … … s n 0 0 1 1 0 b 0 0 0 1 0 ⎠ ⎞ Here, slack variables have been introduced to convert inequalities into
equalities. The tableau is arranged with columns for the decision variables
x 1 , … , x m x_1, \dots, x_m x 1 , … , x m , the game value variable v v v , slack variables s 1 , … , s n s_1, \dots,
s_n s 1 , … , s n , and the right-hand side.
The final row of the tableau has been somewhat artifically added: it does not
correspond to any specific part of (21) .
However this is an important addition to the tableau as it will indicate two
things:
Given a Tableau, we choose to pivot the column with the lowest negative value in
the final row: this corresponds to the variable that will reduce the objective
function the most. When all values in the final row are non-negative we stop
integer pivoting.
We proceed by performing integer pivoting to move from one basic feasible
solution to another, reducing the objective function at each step until
optimality is reached.
Example: Integer Pivoting for Modified Rock-Paper-Scissors ¶ We now solve the modified Rock-Paper-Scissors game
using tableaux. Recall that the standard form coefficients are:
c = ( 0 , 0 , 0 , − 1 ) M ub = ( 0 − 2 1 1 1 0 − 1 1 − 1 2 0 1 ) b ub = ( 0 0 0 ) M eq = ( 1 , 1 , 1 , 0 ) b eq = 1 \begin{aligned}
c &= (0, 0, 0, -1) \\
M_{\text{ub}} &=
\begin{pmatrix}
0 & -2 & 1 & 1 \\
1 & 0 & -1 & 1 \\
-1 & 2 & 0 & 1
\end{pmatrix} \\
b_{\text{ub}} &=
\begin{pmatrix} 0 \\ 0 \\ 0 \end{pmatrix} \\
M_{\text{eq}} &= (1, 1, 1, 0) \\
b_{\text{eq}} &= 1
\end{aligned} c M ub b ub M eq b eq = ( 0 , 0 , 0 , − 1 ) = ⎝ ⎛ 0 1 − 1 − 2 0 2 1 − 1 0 1 1 1 ⎠ ⎞ = ⎝ ⎛ 0 0 0 ⎠ ⎞ = ( 1 , 1 , 1 , 0 ) = 1 To construct the tableau, we introduce slack variables s 1 , s 2 , s 3 s_1, s_2, s_3 s 1 , s 2 , s 3 for the
inequality constraints, and denote the game value variable by v = x 5 v = x_5 v = x 5 .
Initial Tableau ¶ The initial tableau is:
x 1 x 2 x 3 v s 1 s 2 s 3 b 0 − 2 1 1 1 0 0 0 1 0 − 1 1 0 1 0 0 − 1 2 0 1 0 0 1 0 1 1 1 0 0 0 0 1 0 0 0 − 1 0 0 0 0 \begin{array}{ccccccc|c}
x_1 & x_2 & x_3 & v & s_1 & s_2 & s_3 & b \\
0& -2& 1& 1& 1& 0& 0& 0&\\
1& 0& -1&1& 0& 1& 0& 0&\\
-1& 2& 0& 1& 0& 0& 1& 0&\\
1& 1& 1& 0& 0& 0& 0& 1&\\
0& 0& 0& -1& 0& 0& 0& 0&\\
\end{array} x 1 0 1 − 1 1 0 x 2 − 2 0 2 1 0 x 3 1 − 1 0 1 0 v 1 1 1 0 − 1 s 1 1 0 0 0 0 s 2 0 1 0 0 0 s 3 0 0 1 0 0 b 0 0 0 1 0 The last row is the objective function: minimising v v v . We begin by identifying
the entering variable with the most negative coefficient in the objective row,
which is v v v .
Pivot 1: Entering variable v v v ¶ To pivot on v v v , we look at the positive entries in the v v v column (rows 1–3).
All are 1, so we apply the ratio test :
Row 1: 0 / 1 = 0 0 / 1 = 0 0/1 = 0
Row 2: 0 / 1 = 0 0 / 1 = 0 0/1 = 0
Row 3: 0 / 1 = 0 0 / 1 = 0 0/1 = 0
Ties are broken arbitrarily. Suppose we choose row 1:
we subtract appropriate multiples of this row from all others to eliminate
v v v from those rows:
Row 2 ← \gets ← Row 2 - Row 1
Row 3 ← \gets ← Row 3 - Row 1
Objective row = Objective + Row 1
After row operations:
x 1 x 2 x 3 v s 1 s 2 s 3 b 0 − 2 1 1 1 0 0 0 1 2 − 2 0 − 1 1 0 0 − 1 4 − 1 0 − 1 0 1 0 1 1 1 0 0 0 0 1 0 − 2 1 0 1 0 0 0 \begin{array}{ccccccc|c}
x_1 & x_2 & x_3 & v & s_1 & s_2 & s_3 & b \\
0& -2& 1& 1& 1& 0& 0& 0\\
1& 2& -2& 0& -1& 1& 0& 0\\
-1& 4& -1& 0& -1& 0& 1& 0\\
1& 1& 1& 0& 0& 0& 0& 1\\
0& -2& 1& 0& 1& 0& 0& 0
\end{array} x 1 0 1 − 1 1 0 x 2 − 2 2 4 1 − 2 x 3 1 − 2 − 1 1 1 v 1 0 0 0 0 s 1 1 − 1 − 1 0 1 s 2 0 1 0 0 0 s 3 0 0 1 0 0 b 0 0 0 1 0 Pivot 2: Entering variable x 2 x_2 x 2 ¶ Next, inspect the objective row. The most negative coefficient is -2 for x 2 x_2 x 2 .
Apply ratio test on rows with positive x 2 x_2 x 2 entries:
Row 2: 0 / 2 = 0 0 / 2 = 0 0/2 = 0
Row 3: 0 / 4 = 0 0 / 4 = 0 0/4 = 0
Row 4: 1 / 1 = 1 1 / 1 = 1 1/1 = 1
Choose Row 2 (arbitrary tie-break).
Pivot on entry in row 2, column x 2 x_2 x 2 and eliminate
x 2 x_2 x 2 from other rows. After computations, we get:
x 1 x 2 x 3 v s 1 s 2 s 3 b 2 0 − 2 2 0 2 0 0 1 2 − 2 0 − 1 1 0 0 − 6 0 6 0 2 − 4 2 0 1 0 4 0 1 − 1 0 2 2 0 − 2 0 0 2 0 0 \begin{array}{ccccccc|c}
x_1 & x_2 & x_3 & v & s_1 & s_2 & s_3 & b \\
2& 0& -2& 2& 0& 2& 0& 0\\
1& 2& -2& 0& -1& 1& 0& 0\\
-6& 0& 6& 0& 2& -4& 2& 0\\
1& 0& 4& 0& 1& -1& 0& 2\\
2& 0& -2& 0& 0& 2& 0& 0
\end{array} x 1 2 1 − 6 1 2 x 2 0 2 0 0 0 x 3 − 2 − 2 6 4 − 2 v 2 0 0 0 0 s 1 0 − 1 2 1 0 s 2 2 1 − 4 − 1 2 s 3 0 0 2 0 0 b 0 0 0 2 0 Pivot 3: Entering variable x 3 x_3 x 3 ¶ Continue inspecting the objective row. The most negative is now -2 for x 3 x_3 x 3 ,
so it enters. Apply ratio test among positive entries in column x 3 x_3 x 3 .
There is a single candidate: pivot on row 3. Eliminate x 3 x_3 x 3 from other rows.
After computations we get:
x 1 x 2 x 3 v s 1 s 2 s 3 b 0 0 0 12 4 4 4 0 − 6 12 0 0 − 2 − 2 4 0 − 6 0 6 0 2 − 4 2 0 30 0 0 0 − 2 10 − 8 12 0 0 0 0 4 4 4 0 \begin{array}{ccccccc|c}
x_1 & x_2 & x_3 & v & s_1 & s_2 & s_3 & b \\
0& 0& 0& 12& 4& 4& 4& 0\\
-6& 12& 0& 0& -2& -2& 4& 0\\
-6& 0& 6& 0& 2& -4& 2& 0\\
30& 0& 0& 0& -2& 10& -8& 12\\
0& 0& 0& 0& 4& 4& 4& 0
\end{array} x 1 0 − 6 − 6 30 0 x 2 0 12 0 0 0 x 3 0 0 6 0 0 v 12 0 0 0 0 s 1 4 − 2 2 − 2 4 s 2 4 − 2 − 4 10 4 s 3 4 4 2 − 8 4 b 0 0 0 12 0 We now set the non-basic variables to 0 and read the equations for the non-basic
variables:
s 1 = 0 s 2 = 0 s 3 = 0 12 v = 0 − 6 x 1 + 12 x 2 = 0 − 6 x 1 + 6 x 3 = 0 30 x 1 = 12 \begin{align*}
s_1 &=0\\
s_2 &=0 \\
s_3 &=0 \\
12 v &= 0\\
-6x_1 + 12x_2&=0\\
-6x_1 + 6 x_3&=0\\
30x_1 &= 12
\end{align*} s 1 s 2 s 3 12 v − 6 x 1 + 12 x 2 − 6 x 1 + 6 x 3 30 x 1 = 0 = 0 = 0 = 0 = 0 = 0 = 12 This gives:
x = ( 12 / 30 , 6 / 30 , 12 / 30 ) v = 0 x = (12/30, 6/30, 12/30)\qquad v=0 x = ( 12/30 , 6/30 , 12/30 ) v = 0 Thus, the max-min strategy is:
x = ( 2 5 , 1 5 , 2 5 ) x = \left( \frac{2}{5}, \frac{1}{5}, \frac{2}{5} \right) x = ( 5 2 , 5 1 , 5 2 ) Exercises ¶ Programming ¶ Solve linear programs using Scipy ¶ The scipy library provides functionality to solve a linear program in
standard form .
We begin by creating the various matrices and vectors: M u b M_{ub} M u b , M e q M_{eq} M e q ,
b u b b_{ub} b u b , b e q b_{eq} b e q , and c c c :
import numpy as np
M = np.array(
[
[0, -1, 1],
[2, 0, -2],
[-1, 1, 0],
]
)
M_ub = np.hstack((-M.T, [[1], [1], [1]]))
M_eq = np.array(([[1, 1, 1, 0]]))
b_ub = np.array(
[
[0],
[0],
[0],
]
)
b_eq = 1
c = np.array([0, 0, 0, -1])
Now we can pass these to scipy.optimize.linprog:
import scipy.optimize
res = scipy.optimize.linprog(
c=c,
A_ub=M_ub,
b_ub=b_ub,
A_eq=M_eq,
b_eq=b_eq,
)
print(res) message: Optimization terminated successfully. (HiGHS Status 7: Optimal)
success: True
status: 0
fun: 0.0
x: [ 4.000e-01 2.000e-01 4.000e-01 -0.000e+00]
nit: 0
lower: residual: [ 4.000e-01 2.000e-01 4.000e-01 -0.000e+00]
marginals: [ 0.000e+00 0.000e+00 0.000e+00 0.000e+00]
upper: residual: [ inf inf inf inf]
marginals: [ 0.000e+00 0.000e+00 0.000e+00 0.000e+00]
eqlin: residual: [ 0.000e+00]
marginals: [-0.000e+00]
ineqlin: residual: [ 0.000e+00 0.000e+00 0.000e+00]
marginals: [-3.333e-01 -3.333e-01 -3.333e-01]
mip_node_count: 0
mip_dual_bound: 0.0
mip_gap: 0.0
This returns the full output of the optimisation. The min-max strategy is
contained in all but the last entry of res.x:
print(f"Min-max strategy: {res.x[:-1]}")Min-max strategy: [0.4 0.2 0.4]
The last entry of res.x gives the value of the game:
print(f"Value of the game: {res.x[-1]}")Obtain min-max and max-min strategies using Nashpy ¶ nashpy can be used to directly obtain the min-max and max-min strategies:
import nashpy as nash
game = nash.Game(M, -M)
print(game.linear_program())(array([0.4, 0.2, 0.4]), array([0.33333333, 0.33333333, 0.33333333]))
Obtain min-max and max-min strategies using Gambit ¶ Gambit can be used to directly obtain the min-max and max-min strategies. We
start by creating a pygambit game from arrays:
import pygambit as gbt
game = gbt.Game.from_arrays(M, -M)
print(game)Game(title='Untitled strategic game')
Now we can solve the underlying linear program:
print(gbt.nash.lp_solve(game))NashComputationResult(method='lp', rational=True, use_strategic=False, equilibria=[[[Rational(2, 5), Rational(1, 5), Rational(2, 5)], [Rational(1, 3), Rational(1, 3), Rational(1, 3)]]], parameters={})
Notable Research ¶ The foundations of zero-sum game theory and its connection to linear
programming emerged from a convergence of ideas in mathematics, economics, and
operations research during the mid-20th century.
The minimax theorem was first proven by John von Neumann in 1928
Neumann, 1928 . This landmark result, stating that every finite,
two-player zero-sum game has a value and optimal strategies, was later
generalised in 1944 Neumann & Morgenstern, 1944 .
The minimax theorem does not necessarily only apply to zero-sum games but in
fact applies to any constant sum game where M r + M c = K M_r + M_c = K M r + M c = K for some constant
K K K . An example of this is shown in Chiappori et al. , 2002 where penalty kicks
are modelled and the payoff matrices correspond to the probability of
scoring (or for the column player saving) a penalty.
Until the work of Nash Jr, 1950 the minimax theorem was the main solution concept in game theory.
For his foundational work on equilibrium in non-cooperative games,
John Nash was awarded the Nobel Prize in Economic Sciences in 1994,
shared with John Harsanyi and Reinhard Selten.
His contributions form the cornerstone of non-cooperative game theory.
Conclusion ¶ This chapter introduced zero-sum games, where one player’s gain is precisely
balanced by the other’s loss. We explored the foundational minimax theorem, the
max-min and min-max strategies, and showed how linear programming provides a
practical and elegant way to compute optimal strategies.
The central insight of this chapter is the equivalence between solving a
zero-sum game and solving a pair of dual linear programs. This connection
allows us to apply tools from optimisation, such as tableau methods and integer
pivoting, to find equilibrium strategies.
Table 1 summarises the two central linear programs seen in this chapter.
Table 1: The main linear programs for Zero Sum Game
Problem Player Objective Constraints Max-min LP Row player Maximise u u u x M ≥ 1 u x M \geq \mathbb{1} u x M ≥ 1 u , x ∈ A 1 x \in \mathcal{A}_1 x ∈ A 1 Min-max LP Column player Minimise v v v M y T ≤ 1 v M y^T \leq \mathbb{1} v M y T ≤ 1 v , y ∈ A 2 y \in \mathcal{A}_2 y ∈ A 2
Solutions ¶ Recall the Matching Pennies payoff matrix:
M = ( 1 − 1 − 1 1 ) M = \begin{pmatrix} 1 & -1 \\ -1 & 1 \end{pmatrix} M = ( 1 − 1 − 1 1 ) 1. Integer pivoting to confirm max-min strategy x = ( 1 / 2 , 1 / 2 ) x = (1/2, 1/2) x = ( 1/2 , 1/2 ) :
The standard form coefficients are:
c = ( 0 , 0 , − 1 ) , M ub = ( − 1 1 1 1 − 1 1 ) , b ub = ( 0 0 ) , M eq = ( 1 , 1 , 0 ) , b eq = 1 c = (0, 0, -1), \quad
M_{\text{ub}} = \begin{pmatrix} -1 & 1 & 1 \\ 1 & -1 & 1 \end{pmatrix}, \quad
b_{\text{ub}} = \begin{pmatrix} 0 \\ 0 \end{pmatrix}, \quad
M_{\text{eq}} = (1, 1, 0), \quad
b_{\text{eq}} = 1 c = ( 0 , 0 , − 1 ) , M ub = ( − 1 1 1 − 1 1 1 ) , b ub = ( 0 0 ) , M eq = ( 1 , 1 , 0 ) , b eq = 1 The initial tableau (introducing slack variables s 1 , s 2 s_1, s_2 s 1 , s 2 ) is:
x 1 x 2 v s 1 s 2 b − 1 1 1 1 0 0 1 − 1 1 0 1 0 1 1 0 0 0 1 0 0 − 1 0 0 0 \begin{array}{ccccc|c}
x_1 & x_2 & v & s_1 & s_2 & b \\
-1 & 1 & 1 & 1 & 0 & 0 \\
1 & -1 & 1 & 0 & 1 & 0 \\
1 & 1 & 0 & 0 & 0 & 1 \\
0 & 0 & -1 & 0 & 0 & 0
\end{array} x 1 − 1 1 1 0 x 2 1 − 1 1 0 v 1 1 0 − 1 s 1 1 0 0 0 s 2 0 1 0 0 b 0 0 1 0 Pivot 1: Entering variable v v v (most negative objective coefficient = − 1 = -1 = − 1 ).
All entries in the v v v column among constraint rows are 1. Ratio test: all rows give 0 / 1 = 0 0/1 = 0 0/1 = 0 . Choose Row 1 as the pivot row.
Row 2 ← \gets ← Row 2 − - − Row 1
Row 3 stays (Row 3 has no v v v entry)
Objective row ← \gets ← Objective + + + Row 1
x 1 x 2 v s 1 s 2 b − 1 1 1 1 0 0 2 − 2 0 − 1 1 0 1 1 0 0 0 1 − 1 1 0 1 0 0 \begin{array}{ccccc|c}
x_1 & x_2 & v & s_1 & s_2 & b \\
-1 & 1 & 1 & 1 & 0 & 0 \\
2 & -2 & 0 & -1 & 1 & 0 \\
1 & 1 & 0 & 0 & 0 & 1 \\
-1 & 1 & 0 & 1 & 0 & 0
\end{array} x 1 − 1 2 1 − 1 x 2 1 − 2 1 1 v 1 0 0 0 s 1 1 − 1 0 1 s 2 0 1 0 0 b 0 0 1 0 Pivot 2: Entering variable x 1 x_1 x 1 (most negative objective coefficient = − 1 = -1 = − 1 ).
Positive entries in x 1 x_1 x 1 column: Row 2 (2) and Row 3 (1). Ratio test: Row 2 gives 0 / 2 = 0 0/2 = 0 0/2 = 0 , Row 3 gives 1 / 1 = 1 1/1 = 1 1/1 = 1 . Choose Row 2.
Row 1 ← \gets ← Row 1 ⋅ 2 + \cdot 2 + ⋅ 2 + Row 2
Row 3 ← \gets ← Row 3 ⋅ 2 − \cdot 2 - ⋅ 2 − Row 2
Objective ← \gets ← Objective ⋅ 2 + \cdot 2 + ⋅ 2 + Row 2
x 1 x 2 v s 1 s 2 b 0 0 2 1 1 0 2 − 2 0 − 1 1 0 0 4 0 1 − 1 2 0 0 0 1 1 0 \begin{array}{ccccc|c}
x_1 & x_2 & v & s_1 & s_2 & b \\
0 & 0 & 2 & 1 & 1 & 0 \\
2 & -2 & 0 & -1 & 1 & 0 \\
0 & 4 & 0 & 1 & -1 & 2 \\
0 & 0 & 0 & 1 & 1 & 0
\end{array} x 1 0 2 0 0 x 2 0 − 2 4 0 v 2 0 0 0 s 1 1 − 1 1 1 s 2 1 1 − 1 1 b 0 0 2 0 All objective row entries are non-negative: we stop. Setting non-basic variables (s 1 = s 2 = 0 s_1 = s_2 = 0 s 1 = s 2 = 0 ) and reading the system:
2 v = 0 ⟹ v = 0 2v = 0 \implies v = 0 2 v = 0 ⟹ v = 0 2 x 1 − 2 x 2 = 0 ⟹ x 1 = x 2 2x_1 - 2x_2 = 0 \implies x_1 = x_2 2 x 1 − 2 x 2 = 0 ⟹ x 1 = x 2 4 x 2 = 2 ⟹ x 2 = 1 2 4x_2 = 2 \implies x_2 = \frac{1}{2} 4 x 2 = 2 ⟹ x 2 = 2 1 Thus x 1 = x 2 = 1 / 2 x_1 = x_2 = 1/2 x 1 = x 2 = 1/2 , confirming:
x = ( 1 2 , 1 2 ) , v = 0 x = \left(\frac{1}{2},\ \frac{1}{2}\right), \qquad v = 0 x = ( 2 1 , 2 1 ) , v = 0 2. Min-max strategy for the column player:
The column player’s game is given by − M T -M^T − M T . Since M M M is antisymmetric (M = − M T M = -M^T M = − M T for this game), the min-max LP for the column player is identical in structure. Setting M ′ = − M T M' = -M^T M ′ = − M T :
M ′ = − M T = − ( 1 − 1 − 1 1 ) = ( − 1 1 1 − 1 ) M' = -M^T = -\begin{pmatrix} 1 & -1 \\ -1 & 1 \end{pmatrix} = \begin{pmatrix} -1 & 1 \\ 1 & -1 \end{pmatrix} M ′ = − M T = − ( 1 − 1 − 1 1 ) = ( − 1 1 1 − 1 ) By the identical symmetry of the problem, the min-max strategy for the column player is:
y = ( 1 2 , 1 2 ) y = \left(\frac{1}{2},\ \frac{1}{2}\right) y = ( 2 1 , 2 1 ) with min-max value v = 0 v = 0 v = 0 . By the minimax theorem , u = v = 0 u = v = 0 u = v = 0 .
3. Best Response Condition check:
With x = ( 1 / 2 , 1 / 2 ) x = (1/2, 1/2) x = ( 1/2 , 1/2 ) and y = ( 1 / 2 , 1 / 2 ) y = (1/2, 1/2) y = ( 1/2 , 1/2 ) :
M y T = ( 1 − 1 − 1 1 ) ( 1 / 2 1 / 2 ) = ( 0 0 ) M y^T = \begin{pmatrix} 1 & -1 \\ -1 & 1 \end{pmatrix} \begin{pmatrix} 1/2 \\ 1/2 \end{pmatrix} = \begin{pmatrix} 0 \\ 0 \end{pmatrix} M y T = ( 1 − 1 − 1 1 ) ( 1/2 1/2 ) = ( 0 0 ) Both entries equal 0 = max k ( M y T ) k 0 = \max_k (My^T)_k 0 = max k ( M y T ) k , and the support of x x x is { 1 , 2 } \{1, 2\} { 1 , 2 } , so the best response condition is satisfied: x x x is a best response to y y y .
By symmetry:
x M = ( 1 / 2 1 / 2 ) ( 1 − 1 − 1 1 ) = ( 0 0 ) x M = \begin{pmatrix} 1/2 & 1/2 \end{pmatrix} \begin{pmatrix} 1 & -1 \\ -1 & 1 \end{pmatrix} = \begin{pmatrix} 0 & 0 \end{pmatrix} x M = ( 1/2 1/2 ) ( 1 − 1 − 1 1 ) = ( 0 0 ) Both entries of x M xM x M are equal, confirming y y y is a best response to x x x .
Let us confirm this with `nashpy``:
import numpy as np
import nashpy as nash
M = np.array([[1, -1], [-1, 1]])
game = nash.Game(M, -M)
game.linear_program()(array([0.5, 0.5]), array([0.5, 0.5]))
The standard Rock-Paper-Scissors payoff matrix is:
M = ( 0 − 1 1 1 0 − 1 − 1 1 0 ) M = \begin{pmatrix}
0 & -1 & 1 \\
1 & 0 & -1 \\
-1 & 1 & 0
\end{pmatrix} M = ⎝ ⎛ 0 1 − 1 − 1 0 1 1 − 1 0 ⎠ ⎞ The standard form coefficients are:
c = ( 0 , 0 , 0 , − 1 ) c = (0, 0, 0, -1) c = ( 0 , 0 , 0 , − 1 ) M ub = ( 0 − 1 1 1 1 0 − 1 1 − 1 1 0 1 ) b ub = ( 0 0 0 ) M_{\text{ub}} = \begin{pmatrix}
0 & -1 & 1 & 1 \\
1 & 0 & -1 & 1 \\
-1 & 1 & 0 & 1
\end{pmatrix}
\qquad
b_{\text{ub}} = \begin{pmatrix} 0 \\ 0 \\ 0 \end{pmatrix} M ub = ⎝ ⎛ 0 1 − 1 − 1 0 1 1 − 1 0 1 1 1 ⎠ ⎞ b ub = ⎝ ⎛ 0 0 0 ⎠ ⎞ M eq = ( 1 , 1 , 1 , 0 ) , b eq = 1 M_{\text{eq}} = (1, 1, 1, 0), \qquad b_{\text{eq}} = 1 M eq = ( 1 , 1 , 1 , 0 ) , b eq = 1 Integer pivoting:
Initial tableau:
x 1 x 2 x 3 v s 1 s 2 s 3 b 0 − 1 1 1 1 0 0 0 1 0 − 1 1 0 1 0 0 − 1 1 0 1 0 0 1 0 1 1 1 0 0 0 0 1 0 0 0 − 1 0 0 0 0 \begin{array}{ccccccc|c}
x_1 & x_2 & x_3 & v & s_1 & s_2 & s_3 & b \\
0 & -1 & 1 & 1 & 1 & 0 & 0 & 0 \\
1 & 0 & -1 & 1 & 0 & 1 & 0 & 0 \\
-1 & 1 & 0 & 1 & 0 & 0 & 1 & 0 \\
1 & 1 & 1 & 0 & 0 & 0 & 0 & 1 \\
0 & 0 & 0 & -1 & 0 & 0 & 0 & 0
\end{array} x 1 0 1 − 1 1 0 x 2 − 1 0 1 1 0 x 3 1 − 1 0 1 0 v 1 1 1 0 − 1 s 1 1 0 0 0 0 s 2 0 1 0 0 0 s 3 0 0 1 0 0 b 0 0 0 1 0 Pivot 1: v v v enters (coefficient -1). Choose Row 1 (ratio 0 / 1 = 0 0/1 = 0 0/1 = 0 ).
Row 2 ← \gets ← Row 2 − - − Row 1: ( 1 , 1 , − 2 , 0 , − 1 , 1 , 0 , 0 ) (1, 1, -2, 0, -1, 1, 0, 0) ( 1 , 1 , − 2 , 0 , − 1 , 1 , 0 , 0 )
Row 3 ← \gets ← Row 3 − - − Row 1: ( − 1 , 2 , − 1 , 0 , − 1 , 0 , 1 , 0 ) (-1, 2, -1, 0, -1, 0, 1, 0) ( − 1 , 2 , − 1 , 0 , − 1 , 0 , 1 , 0 )
Objective ← \gets ← Objective + + + Row 1: ( 0 , − 1 , 1 , 0 , 1 , 0 , 0 , 0 ) (0, -1, 1, 0, 1, 0, 0, 0) ( 0 , − 1 , 1 , 0 , 1 , 0 , 0 , 0 )
0 − 1 1 1 1 0 0 0 1 1 − 2 0 − 1 1 0 0 − 1 2 − 1 0 − 1 0 1 0 1 1 1 0 0 0 0 1 0 − 1 1 0 1 0 0 0 \begin{array}{ccccccc|c}
0 & -1 & 1 & 1 & 1 & 0 & 0 & 0 \\
1 & 1 & -2 & 0 & -1 & 1 & 0 & 0 \\
-1 & 2 & -1 & 0 & -1 & 0 & 1 & 0 \\
1 & 1 & 1 & 0 & 0 & 0 & 0 & 1 \\
0 & -1 & 1 & 0 & 1 & 0 & 0 & 0
\end{array} 0 1 − 1 1 0 − 1 1 2 1 − 1 1 − 2 − 1 1 1 1 0 0 0 0 1 − 1 − 1 0 1 0 1 0 0 0 0 0 1 0 0 0 0 0 1 0 Pivot 2: x 2 x_2 x 2 enters (coefficient -1). Positive entries in x 2 x_2 x 2 column: Row 2 (1, ratio 0), Row 3 (2, ratio 0), Row 4 (1, ratio 1). Choose Row 2 (tie-break).
Pivot on ( 2 , x 2 ) (2, x_2) ( 2 , x 2 ) , entry = 1. Eliminate x 2 x_2 x 2 from other rows:
Row 1 ← \gets ← Row 1 + + + Row 2: ( 1 , 0 , − 1 , 1 , 0 , 1 , 0 , 0 ) (1, 0, -1, 1, 0, 1, 0, 0) ( 1 , 0 , − 1 , 1 , 0 , 1 , 0 , 0 )
Row 3 ← \gets ← Row 3 − - − 2 ⋅ 2 \cdot 2 ⋅ Row 2: ( − 3 , 0 , 3 , 0 , 1 , − 2 , 1 , 0 ) (-3, 0, 3, 0, 1, -2, 1, 0) ( − 3 , 0 , 3 , 0 , 1 , − 2 , 1 , 0 )
Row 4 ← \gets ← Row 4 − - − Row 2: ( 0 , 0 , 3 , 0 , 1 , − 1 , 0 , 1 ) (0, 0, 3, 0, 1, -1, 0, 1) ( 0 , 0 , 3 , 0 , 1 , − 1 , 0 , 1 )
Objective ← \gets ← Objective + + + Row 2: ( 1 , 0 , − 1 , 0 , 0 , 1 , 0 , 0 ) (1, 0, -1, 0, 0, 1, 0, 0) ( 1 , 0 , − 1 , 0 , 0 , 1 , 0 , 0 )
1 0 − 1 1 0 1 0 0 1 1 − 2 0 − 1 1 0 0 − 3 0 3 0 1 − 2 1 0 0 0 3 0 1 − 1 0 1 1 0 − 1 0 0 1 0 0 \begin{array}{ccccccc|c}
1 & 0 & -1 & 1 & 0 & 1 & 0 & 0 \\
1 & 1 & -2 & 0 & -1 & 1 & 0 & 0 \\
-3 & 0 & 3 & 0 & 1 & -2 & 1 & 0 \\
0 & 0 & 3 & 0 & 1 & -1 & 0 & 1 \\
1 & 0 & -1 & 0 & 0 & 1 & 0 & 0
\end{array} 1 1 − 3 0 1 0 1 0 0 0 − 1 − 2 3 3 − 1 1 0 0 0 0 0 − 1 1 1 0 1 1 − 2 − 1 1 0 0 1 0 0 0 0 0 1 0 Pivot 3: x 3 x_3 x 3 enters (coefficient -1). Positive entries in x 3 x_3 x 3 column: Row 3 (3, ratio 0 / 3 = 0 0/3 = 0 0/3 = 0 ), Row 4 (3, ratio 1 / 3 1/3 1/3 ). Choose Row 3.
Pivot on ( 3 , x 3 ) (3, x_3) ( 3 , x 3 ) , entry = 3. Eliminate x 3 x_3 x 3 from other rows:
Row 1 ← \gets ← 3 ⋅ \cdot ⋅ Row 1 + + + Row 3: ( 0 , 0 , 0 , 3 , 1 , 1 , 1 , 0 ) (0, 0, 0, 3, 1, 1, 1, 0) ( 0 , 0 , 0 , 3 , 1 , 1 , 1 , 0 )
Row 2 ← \gets ← 3 ⋅ \cdot ⋅ Row 2 + + + 2 ⋅ \cdot ⋅ Row 3: ( − 3 , 3 , 0 , 0 , − 1 , − 1 , 2 , 0 ) (-3, 3, 0, 0, -1, -1, 2, 0) ( − 3 , 3 , 0 , 0 , − 1 , − 1 , 2 , 0 )
Row 4 ← \gets ← 3 ⋅ \cdot ⋅ Row 4 − - − 3 ⋅ \cdot ⋅ Row 3: ( 9 , 0 , 0 , 0 , 0 , 3 , − 3 , 3 ) (9, 0, 0, 0, 0, 3, -3, 3) ( 9 , 0 , 0 , 0 , 0 , 3 , − 3 , 3 )
Objective ← \gets ← 3 ⋅ \cdot ⋅ Objective + + + Row 3: ( 0 , 0 , 0 , 0 , 1 , 1 , 1 , 0 ) (0, 0, 0, 0, 1, 1, 1, 0) ( 0 , 0 , 0 , 0 , 1 , 1 , 1 , 0 )
x 1 x 2 x 3 v s 1 s 2 s 3 b 0 0 0 3 1 1 1 0 − 3 3 0 0 − 1 − 1 2 0 − 3 0 3 0 1 − 2 1 0 9 0 0 0 0 3 − 3 3 0 0 0 0 1 1 1 0 \begin{array}{ccccccc|c}
x_1 & x_2 & x_3 & v & s_1 & s_2 & s_3 & b \\
0 & 0 & 0 & 3 & 1 & 1 & 1 & 0 \\
-3 & 3 & 0 & 0 & -1 & -1 & 2 & 0 \\
-3 & 0 & 3 & 0 & 1 & -2 & 1 & 0 \\
9 & 0 & 0 & 0 & 0 & 3 & -3 & 3 \\
0 & 0 & 0 & 0 & 1 & 1 & 1 & 0
\end{array} x 1 0 − 3 − 3 9 0 x 2 0 3 0 0 0 x 3 0 0 3 0 0 v 3 0 0 0 0 s 1 1 − 1 1 0 1 s 2 1 − 1 − 2 3 1 s 3 1 2 1 − 3 1 b 0 0 0 3 0 All entries in the objective row are non-negative: we stop. Setting non-basic variables (s 1 = s 2 = s 3 = 0 s_1 = s_2 = s_3 = 0 s 1 = s 2 = s 3 = 0 ) and reading the equations:
3 v = 0 − 3 x 1 + 3 x 2 = 0 − 3 x 1 + 3 x 3 = 0 9 x 1 = 3 \begin{align*}
3v &= 0 \\
-3x_1 + 3x_2 &= 0 \\
-3x_1 + 3x_3 &= 0 \\
9x_1 &= 3
\end{align*} 3 v − 3 x 1 + 3 x 2 − 3 x 1 + 3 x 3 9 x 1 = 0 = 0 = 0 = 3 This gives v = 0 v = 0 v = 0 , x 1 = x 2 = x 3 x_1 = x_2 = x_3 x 1 = x 2 = x 3 , and x 1 = 1 / 3 x_1 = 1/3 x 1 = 1/3 .
Thus:
x = ( 1 3 , 1 3 , 1 3 ) , v = 0 x = \left(\frac{1}{3},\ \frac{1}{3},\ \frac{1}{3}\right), \qquad v = 0 x = ( 3 1 , 3 1 , 3 1 ) , v = 0 Let us confirm this with nashpy:
import numpy as np
import nashpy as nash
M = np.array([[0, -1, 1], [1, 0, -1], [-1, 1, 0]])
game = nash.Game(M, -M)
game.linear_program()(array([0.33333333, 0.33333333, 0.33333333]),
array([0.33333333, 0.33333333, 0.33333333]))
v. Neumann, J. (1928). Zur theorie der gesellschaftsspiele. Mathematische Annalen , 100 (1), 295–320. Vanderbei, R. J. (2010). Linear Programming: Foundations and Extensions (Softcover reprint of hardcover 3rd Edition 2008). Springer Science+Business Media. von Neumann, J. (1928). Zur Theorie der Gesellschaftsspiele. Mathematische Annalen , 100 (1), 295–320. von Neumann, J., & Morgenstern, O. (1944). Theory of Games and Economic Behavior . Princeton University Press. Chiappori, P.-A., Levitt, S., & Groseclose, T. (2002). Testing mixed-strategy equilibria when players are heterogeneous: The case of penalty kicks in soccer. American Economic Review , 92 (4), 1138–1151. Nash Jr, J. F. (1950). Equilibrium points in n-person games. Proceedings of the National Academy of Sciences , 36 (1), 48–49.