Skip to article frontmatterSkip to article content

Cooperative Games

Example: Dividing the loot after a D&D battle

After a climactic boss fight, a party of adventurers must divide a hoard of
1,000 gold coins recovered after fighting a dragon.

The party includes:

  • Ren the fighter, who absorbed the dragon’s attacks.
  • Azel the wizard, who cast a decisive spell at the turning point.
  • Quinn the bard, who provided support and distracted the dragon
    with an improvised limerick.

Each character played a crucial role, but in very different ways. How can they
divide the treasure fairly?

Based on past encounters, the party has a sense of how much gold they might
have secured without the full team:

This is a classic example of a cooperative game, and understanding how to
allocate resources fairly in such settings is the focus of this chapter.

Theory

Definition: characteristic function game

A characteristic function game GG is given by a pair
(N,v)(N, v) where NN is the number of players and
v:2[N]Rv: 2^{[N]} \to \mathbb{R} is a characteristic function which
maps every coalition of players to a payoff.

Example: The characteristic function game of the D&D battle

For the D&D battle, we have N=3N = 3 and the
characteristic function vv is given by:

v(c)={0if c=0if c={Ren}0if c={Azel}0if c={Quinn}900if c={Ren,Azel}400if c={Ren,Quinn}600if c={Azel,Quinn}1000if c={Ren,Azel,Quinn}v(c) = \begin{cases} 0 & \text{if } c = \emptyset \\ 0 & \text{if } c = \{\text{Ren}\} \\ 0 & \text{if } c = \{\text{Azel}\} \\ 0 & \text{if } c = \{\text{Quinn}\} \\ 900 & \text{if } c = \{\text{Ren}, \text{Azel}\} \\ 400 & \text{if } c = \{\text{Ren}, \text{Quinn}\} \\ 600 & \text{if } c = \{\text{Azel}, \text{Quinn}\} \\ 1000 & \text{if } c = \{\text{Ren}, \text{Azel}, \text{Quinn}\} \end{cases}

Definition: Monotone characteristic function game


A characteristic function game G=(N,v)G = (N, v) is called monotone if it satisfies
v(C2)v(C1)v(C_2) \geq v(C_1) for all C1C2C_1 \subseteq C_2.


Example: The D&D battle is a monotone characteristic function game

The function defined in (1) is monotone.
However, the following game is not:

v(c)={0if c=0if c={Ren}0if c={Azel}0if c={Quinn}1100if c={Ren,Azel}400if c={Ren,Quinn}600if c={Azel,Quinn}1000if c={Ren,Azel,Quinn}v(c) = \begin{cases} 0 & \text{if } c = \emptyset \\ 0 & \text{if } c = \{\text{Ren}\} \\ 0 & \text{if } c = \{\text{Azel}\} \\ 0 & \text{if } c = \{\text{Quinn}\} \\ 1100 & \text{if } c = \{\text{Ren}, \text{Azel}\} \\ 400 & \text{if } c = \{\text{Ren}, \text{Quinn}\} \\ 600 & \text{if } c = \{\text{Azel}, \text{Quinn}\} \\ 1000 & \text{if } c = \{\text{Ren}, \text{Azel}, \text{Quinn}\} \end{cases}

Indeed, Ren and Azel receive more without Quinn than with them, violating monotonicity.

Definition: superadditive characteristic function game

A characteristic function game G=(N,v)G = (N, v) is called superadditive if it satisfies
v(C1C2)v(C1)+v(C2)v(C_1 \cup C_2) \geq v(C_1) + v(C_2) for all disjoint coalitions
C1C2=C_1 \cap C_2 = \emptyset.


Example: The D&D battle is not a superadditive characteristic function game

The function defined in (1) is superadditive.
However, the following game is not:

v(c)={0if c=0if c={Ren}700if c={Azel}0if c={Quinn}900if c={Ren,Azel}400if c={Ren,Quinn}600if c={Azel,Quinn}1000if c={Ren,Azel,Quinn}v(c) = \begin{cases} 0 & \text{if } c = \emptyset \\ 0 & \text{if } c = \{\text{Ren}\} \\ 700 & \text{if } c = \{\text{Azel}\} \\ 0 & \text{if } c = \{\text{Quinn}\} \\ 900 & \text{if } c = \{\text{Ren}, \text{Azel}\} \\ 400 & \text{if } c = \{\text{Ren}, \text{Quinn}\} \\ 600 & \text{if } c = \{\text{Azel}, \text{Quinn}\} \\ 1000 & \text{if } c = \{\text{Ren}, \text{Azel}, \text{Quinn}\} \end{cases}

Indeed:

v({Ren,Quinn})+v({Azel})=400+700=1100>1000=v({Ren,Azel,Quinn})v(\{\text{Ren}, \text{Quinn}\}) + v(\{\text{Azel}\}) = 400 + 700 = 1100 > 1000 = v(\{\text{Ren}, \text{Azel}, \text{Quinn}\})

so the game violates superadditivity.

Definition: Payoff vector

When we talk about a solution to a characteristic function game, we mean a
payoff vector λR0N\lambda \in \mathbb{R}_{\geq 0}^N that allocates the value of
the grand coalition among the players. In particular, λ\lambda must satisfy:

i=1Nλi=v(Ω)\sum_{i=1}^N \lambda_i = v(\Omega)

Example: A possible payoff vector:

One possible payoff vector for (1) is:

λ=(200,350,450)\lambda = (200, 350, 450)

This would seem unfair as Quinn gets 450 of the gold. To find a “fair” distribution of the grand coalition we must define what is meant by “fair”. We require four desirable properties:

Definition: Efficiency


Given a game G=(N,v)G = (N, v), a payoff vector λ\lambda is efficient if:

i=1Nλi=v(Ω)\sum_{i=1}^N \lambda_i = v(\Omega)

Example: An efficient Payoff Vector for the D&D Battle

An efficient payoff vector is one that shares all 1,000 gold coins like the one in (6).


Definition: Null Player Property


Given a game G=(N,v)G = (N, v), a payoff vector xx satisfies the null player property if, for a player ii:

If v(Ci)=v(C)v(C \cup i) = v(C) for all coalitions CΩC \subseteq \Omega, then:

xi=0x_i = 0

Example: The Null Player Property in the D&D Battle

In Example: Dividing the loot after a D&D battle, Quinn contributes very little, yet still adds value to each coalition he joins. For instance, without Quinn, the grand coalition would only obtain 900 coins. If, however, a member of the party made no difference to the value of any coalition, the null player property dictates that this player should receive a payoff of 0.


Definition: Symmetry Property


Given a game G=(N,v)G = (N, v), a payoff vector xx satisfies the symmetry property if, for any pair of players i,ji, j:

If v(Ci)=v(Cj)v(C \cup i) = v(C \cup j) for all coalitions CΩ{i,j}C \subseteq \Omega \setminus \{i, j\}, then:

xi=xjx_i = x_j

Example: The Symmetry Property in the D&D Battle

In Example: Dividing the loot after a D&D battle, no two players contribute equally to every coalition they join. If there were such players, the symmetry property would guarantee that they each receive an equal share of the gold

Definition: Additivity Property


Given two games G1=(N,v1)G_1 = (N, v_1) and G2=(N,v2)G_2 = (N, v_2), define their sum G+=(N,v+)G^+ = (N, v^+) by:

v+(C)=v1(C)+v2(C)for all CΩv^+(C) = v_1(C) + v_2(C) \quad \text{for all } C \subseteq \Omega

A payoff vector xx satisfies the additivity property if:

xi(G+)=xi(G1)+xi(G2)x_i^{(G^+)} = x_i^{(G_1)} + x_i^{(G_2)}

Example: The Additive Property in the D&D Battle

In Example: Dividing the loot after a D&D battle, if there were in fact two separate battles, the method for distributing the gold should
yield the same result as treating both battles as a single event with the
combined total reward.

Definition: Predecessors


Given a permutation π\pi of [N][N], the set of predecessors of player ii in π\pi is denoted by Spi(i)S_pi(i) and defined as:

Sπ(i)={j[N]π(j)<π(i)}S_\pi(i)=\{j \in [N] \mid \pi(j)<\pi(i)\}

Example: The predecessors for the D&D Battle

For Example: Dividing the loot after a D&D battle we have N=3N=3 if we assume the ordering: (Ren,Azel,Quinn)(\text{Ren}, \text{Azel}, \text{Quinn}) Table 1 gives the predecessors of each individual for each of the 3!=63!=6 permutations of [N][N].

Table 1:The predecessors of each individual for each permutation

π\piSπ(1)S_{\pi}(1) (Predecessors of Ren)Sπ(2)S_{\pi}(2) (Predecessors of Azel)Sπ(3)S_{\pi}(3) (Predecessors of Quinn)
(1,2,3)(1, 2, 3)\emptyset{1}\{1\}{1,2}\{1, 2\}
(1,3,2)(1, 3, 2)\emptyset{1,3}\{1, 3\}{1}\{1\}
(2,1,3)(2, 1, 3){2}\{2\}\emptyset{1,2}\{1, 2\}
(2,3,1)(2, 3, 1){2,3}\{2, 3\}\emptyset{2}\{2\}
(3,1,2)(3, 1, 2){3}\{3\}{1,3}\{1, 3\}\emptyset
(3,2,1)(3, 2, 1){2,3}\{2, 3\}{3}\{3\}\emptyset

Definition: Marginal Contribution


Given a permutation π\pi of [N][N], the marginal contribution of player ii with respect to π\pi is defined as:

ΔπG(i)=v(Sπ(i){i})v(Sπ(i))\Delta_\pi^G(i)=v(S_{\pi}(i)\cup \{i\})-v(S_{\pi}(i))

Example: Marginal Contributions in the D&D Battle

For Example: Dividing the loot after a D&D battle (Ren,Azel,Quinn)(\text{Ren}, \text{Azel}, \text{Quinn}), with N=3N = 3. Table 2 shows the marginal contribution ΔπG(i)\Delta_\pi^G(i) for each player ii in each permutation π\pi using (1).

Table 2:Marginal contributions of each individual for each permutation

π\piΔπG(1)\Delta_\pi^G(1) (Ren)ΔπG(2)\Delta_\pi^G(2) (Azel)ΔπG(3)\Delta_\pi^G(3) (Quinn)
(1,2,3)(1, 2, 3)0900100
(1,3,2)(1, 3, 2)0600400
(2,1,3)(2, 1, 3)9000100
(2,3,1)(2, 3, 1)4000600
(3,1,2)(3, 1, 2)4006000
(3,2,1)(3, 2, 1)4006000

We are now ready to define the Shapley value for any cooperative game G=(N,v)G=(N,v).

Definition: Shapley Value


Given a cooperative game G=(N,v)G=(N,v), the Shapley value of player ii is denoted by ϕi(G)\phi_i(G) and defined as:

ϕi(G)=1N!πΠnΔπG(i)\phi_i(G)=\frac{1}{N!}\sum_{\pi\in\Pi_n}\Delta_\pi^G(i)

Example: The Shapley Value for the D&D Battle

For Example: Dividing the loot after a D&D battle the Shapley value is the vector with entries corresponding to the average of each of the columnts of Table 2.

ϕ1=0+0+900+400+400+4006=350ϕ2=900+600+0+0+400+6006=450ϕ3=100+400+100+600+0+06=200\begin{align*} \phi_1 &= \frac{0 + 0 + 900 + 400 + 400 + 400}{6} = 350\\ \phi_2 &= \frac{900 + 600 + 0 + 0 + 400 + 600}{6} = 450\\ \phi_3 &= \frac{100 + 400 + 100 + 600 + 0 + 0}{6} = 200\\ \end{align*}

Giving: ϕ=(350,450,200)\phi=(350, 450, 200)

Exercises

Exercise: Shapley Value Computation and Properties

For the following cooperative games:

  1. Verify whether the game is monotonic.
  2. Verify whether the game is superadditive.
  3. Obtain the Shapley value.
v1(C)={5,if C={1}3,if C={2}2,if C={3}12,if C={1,2}5,if C={1,3}4,if C={2,3}13,if C={1,2,3}v_1(C)=\begin{cases} 5,&\text{if }C=\{1\}\\ 3,&\text{if }C=\{2\}\\ 2,&\text{if }C=\{3\}\\ 12,&\text{if }C=\{1,2\}\\ 5,&\text{if }C=\{1,3\}\\ 4,&\text{if }C=\{2,3\}\\ 13,&\text{if }C=\{1,2,3\} \end{cases}
v2(C)={6,if C={1}0,if C={2}5,if C={1,2}v_2(C)=\begin{cases} 6,&\text{if }C=\{1\}\\ 0,&\text{if }C=\{2\}\\ 5,&\text{if }C=\{1,2\} \end{cases}
v3(C)={6,if C={1}6,if C={2}13,if C={3}6,if C={1,2}13,if C={1,3}13,if C={2,3}26,if C={1,2,3}v_3(C)=\begin{cases} 6,&\text{if }C=\{1\}\\ 6,&\text{if }C=\{2\}\\ 13,&\text{if }C=\{3\}\\ 6,&\text{if }C=\{1,2\}\\ 13,&\text{if }C=\{1,3\}\\ 13,&\text{if }C=\{2,3\}\\ 26,&\text{if }C=\{1,2,3\} \end{cases}
v4(C)={6,if C={1}7,if C={2}0,if C={3}8,if C={4}7,if C={1,2}6,if C={1,3}12,if C={1,4}7,if C={2,3}12,if C={2,4}8,if C={3,4}7,if C={1,2,3}24,if C={1,2,4}12,if C={1,3,4}12,if C={2,3,4}25,if C={1,2,3,4}v_4(C)=\begin{cases} 6,&\text{if }C=\{1\}\\ 7,&\text{if }C=\{2\}\\ 0,&\text{if }C=\{3\}\\ 8,&\text{if }C=\{4\}\\ 7,&\text{if }C=\{1,2\}\\ 6,&\text{if }C=\{1,3\}\\ 12,&\text{if }C=\{1,4\}\\ 7,&\text{if }C=\{2,3\}\\ 12,&\text{if }C=\{2,4\}\\ 8,&\text{if }C=\{3,4\}\\ 7,&\text{if }C=\{1,2,3\}\\ 24,&\text{if }C=\{1,2,4\}\\ 12,&\text{if }C=\{1,3,4\}\\ 12,&\text{if }C=\{2,3,4\}\\ 25,&\text{if }C=\{1,2,3,4\} \end{cases}

Exercise: Interpreting linear model performance with the Shapley value

In statistics and machine learning, a linear model predicts a target variable yy as a weighted sum of input features x1,x2,,xnx_1, x_2, \dots, x_n. The coefficient of determination, denoted R2R^2, measures how well the model explains the variance in the data. It takes values between 0 and 1, with higher values indicating better explanatory power.

In cooperative game theory, a characteristic function maps every coalition (subset of players) to a value. In this exercise, we will interpret each feature as a player, and define the value of a coalition to be the R2R^2 of the model trained on those features.

Suppose we are predicting a target variable yy using a linear model:

y=c1x1+c2x2+c3x3y = c_1 x_1 + c_2 x_2 + c_3 x_3

Below are the R2R^2 values obtained from fitting models to different subsets of the features. These were generated using synthetic data (you can refer to :download:main.py </_static/data-for-shapley-regression-tutorial/main.py> for the code).

ModelR2R^2
y=c1x1y = c_1 x_10.122
y=c1x1+c2x2y = \phantom{c_1 x_1 +{}} c_2 x_20.097
y=c1x1+c2x2+c3x3y = \phantom{c_1 x_1 + c_2 x_2 +{}} c_3 x_30.551
y=c1x1+c2x2y = c_1 x_1 + c_2 x_20.174
y=c1x1+c3x3y = c_1 x_1 + c_3 x_30.581
y=c2x2+c3x3y = c_2 x_2 + c_3 x_30.620
y=c1x1+c2x2+c3x3y = c_1 x_1 + c_2 x_2 + c_3 x_30.623
  1. Define the characteristic function v(S)v(S) for each subset of {x1,x2,x3}\{x_1, x_2, x_3\} using the table above.

  2. Compute the Shapley value for each feature with respect to the characteristic function vv.

  3. Interpret the result: Which feature contributes the most explanatory power? Which contributes the least?

Exercise: Additivity and Symmetry

Consider the following two cooperative games defined on N={1,2,3}N=\{1,2,3\}:

Game vav_a:

va(C)={2,if C={1}2,if C={2}0,otherwisev_a(C)=\begin{cases} 2, &\text{if }C=\{1\}\\ 2, &\text{if }C=\{2\}\\ 0, &\text{otherwise} \end{cases}

Game vbv_b:

vb(C)={1,if C={1,3}1,if C={2,3}3,if C={1,2,3}0,otherwisev_b(C)=\begin{cases} 1, &\text{if }C=\{1,3\}\\ 1, &\text{if }C=\{2,3\}\\ 3, &\text{if }C=\{1,2,3\}\\ 0, &\text{otherwise} \end{cases}
  1. Verify that both games satisfy the symmetry property.
  2. Obtain the Shapley value for vav_a and vbv_b individually.
  3. Construct the game (va+vb)(v_a + v_b) and calculate the Shapley value.
  4. Verify that the Shapley value of (va+vb)(v_a + v_b) equals the sum of the Shapley values of vav_a and vbv_b.

Exercise: Null Player and Marginal Contributions

Consider the cooperative game vv defined on N={1,2,3}N=\{1,2,3\}:

v(C)={4,if C={1}7,if C={1,2}7,if C={1,2,3}0,otherwisev(C)=\begin{cases} 4, &\text{if }C=\{1\}\\ 7, &\text{if }C=\{1,2\}\\ 7, &\text{if }C=\{1,2,3\}\\ 0, &\text{otherwise} \end{cases}
  1. Identify any null players in this game.
  2. Compute the marginal contributions of each player.
  3. Calculate the Shapley value and confirm it respects the null player property.

Exercise: Properties of the Shapley Value

Prove that the Shapley value satisfies the following properties:

Note that this does not prove uniqueness; that is, other vectors might satisfy these properties (though in fact, the Shapley value is uniquely defined by them).

Programming

The CoopGT library has functionality to verify properties of a characteristic function game and also compute the Shapley value.

Here let us define a characteristic function and check if it is valid:

import coopgt.characteristic_function_properties


characteristic_function = {
    (): 0,
    (1,): 0,
    (2,): 0,
    (3,): 0,
    (1, 2): 900,
    (1,3): 400,
    (2, 3): 600,
    (1, 2, 3): 1000,
}
coopgt.characteristic_function_properties.is_valid(characteristic_function=characteristic_function)

Here we can check if it is monotone:

coopgt.characteristic_function_properties.is_monotone(
    characteristic_function=characteristic_function
)

Here we can check if it is supperadditive:

coopgt.characteristic_function_properties.is_superadditive(
    characteristic_function=characteristic_function
)

Let us compute the Shapley value:

import coopgt.shapley_value

coopgt.shapley_value.calculate(characteristic_function=characteristic_function)

Notable Research

The Shapley value was first introduced by Shapley in Shapley & others, 1953, a foundational paper in cooperative game theory. Although Shapley is best known for this concept, he was awarded the Nobel Prize in Economics for his later work on matching games.

In large games, the computational cost of calculating the Shapley value can be prohibitive. While not necessarily intractable in the formal sense, as shown in Deng & Papadimitriou, 1994, the number of permutations makes exact computation impractical. One of the earliest practical approaches to this challenge is Castro et al., 2009, which proposes Monte Carlo sampling of permutations as an efficient approximation method.

One of the most impactful application areas of the Shapley value in recent years has been in model explainability. As explored in #exercise:interpreting_linear_models, the Shapley value provides a principled way to attribute a model’s output to its input features. One of the first papers to formalize this idea was Strumbelj & Kononenko, 2010. This approach has since seen wide application, particularly in healthcare, where a comprehensive overview is provided in Jin et al., 2022.

Conclusion

In this chapter, we introduced the theory of cooperative games, where groups of players can form coalitions and share the resulting value. We focused on characteristic function games, where the value of each coalition is known, and explored how to fairly distribute this value using the Shapley value.

We discussed the key axioms that characterize fairness—efficiency, null player, symmetry, and additivity and saw how they uniquely determine the Shapley value. We also explored computational aspects, applications to machine learning, and interactive programming tools to calculate Shapley values.

Table 3 gives a summary of the concepts of this chapter.

Table 3:Summary of cooperative game concepts

ConceptDescription
Characteristic functionMaps each subset (coalition) of players to a real-valued payoff
MonotonicityAdding players to a coalition cannot decrease its value
SuperadditivityThe value of two disjoint coalitions is at most the value of their union
Payoff vectorA distribution of the total value among all players
Marginal contributionThe added value a player brings to a coalition
Predecessors in permutationPlayers who appear before a given player in a permutation
Shapley valueThe average marginal contribution: a unique, fair payoff satisfying four axioms
References
  1. Shapley, L. S., & others. (1953). A value for n-person games.
  2. Deng, X., & Papadimitriou, C. H. (1994). On the complexity of cooperative solution concepts. Mathematics of Operations Research, 19(2), 257–266.
  3. Castro, J., Gómez, D., & Tejada, J. (2009). Polynomial calculation of the Shapley value based on sampling. Computers & Operations Research, 36(5), 1726–1730.
  4. Strumbelj, E., & Kononenko, I. (2010). An efficient explanation of individual classifications using game theory. The Journal of Machine Learning Research, 11, 1–18.
  5. Jin, D., Sergeeva, E., Weng, W.-H., Chauhan, G., & Szolovits, P. (2022). Explainable deep learning in healthcare: A methodological survey from an attribution view. WIREs Mechanisms of Disease, 14(3), e1548.