Game theory is the study of interactive decision making. Consider the following situation:
Two friends must decide what movie to watch at the cinema. Alice would like to watch a sport movie and Bob would like to watch a comedy. Importantly they would both rather spend their evening together then apart.
To represent this mathematically we will associate utilities to the 4 possible outcomes:
This is referred to as the "battle of the sexes" and we will represent it using two matrices, $A$ will represent the utilities of Alice:
$$ A = \begin{pmatrix} 3 & 1\\ 0 & 2 \end{pmatrix} $$and matrix $B$ will represent the utilities of Bob:
$$ B = \begin{pmatrix} 2 & 1\\ 0 & 3 \end{pmatrix} $$We refer to Alice as the row player and Bob as the column player:
Thus if the row player (Alice) chooses the first row (this corresponds to a sport movie) and the column player (Bob) chooses the second column (this corresponds to a comedy):
This representation of the stategic interaction between Alice and Bob is called a Normal Form Game.
An $N$ player normal form game consists of:
In this course we will only consider the case of $N=2$.
For the battle of the sexes:
The payoff functions mapping an element of $\tilde s \in S_1\times S_2=\{(1, 1), (1, 2), (2, 1), (2, 2)\}$ to $\mathbb{R}$:
$$u_1(\tilde s)=A_{\tilde s},$$
$$u_2(\tilde s)=B_{\tilde s}.$$
We can use Python to represent these games, we will use the nashpy
library to do so and we start by building our two matrices:
In [1]:
import nashpy as nash
A = [[3, 1], [0, 2]]
B = [[2, 1], [0, 3]]
We then create a nash.Game
instance:
In [2]:
battle_of_the_sexes = nash.Game(A, B)
battle_of_the_sexes
Out[2]:
In the next chapter we will start to see how to use that for further calculations.
Assume two thieves have been caught by the police and separated for questioning. If both thieves cooperate and don’t divulge any information they will each get a short sentence. If one defects he/she is offered a deal while the other thief will get a long sentence. If they both defect they both get a medium length sentence.
This corresponds to:
$$ A = \begin{pmatrix} 3 & 0\\ 5 & 1 \end{pmatrix}\qquad B = \begin{pmatrix} 3 & 5\\ 0 & 1 \end{pmatrix} $$
In [3]:
A = [[3, 0], [5, 1]]
B = [[3, 5], [0, 1]]
prisoners_dilemma = nash.Game(A, B)
prisoners_dilemma
Out[3]:
Suppose two birds of prey must share a limited resource. The birds can act like a hawk or a dove. Hawks always fight over the resource to the point of exterminating a fellow hawk and/or take a majority of the resource from a dove. Two doves can share the resource.
This corresponds to:
$$ A = \begin{pmatrix} 0 & 3\\ 1 & 2 \end{pmatrix}\qquad B = \begin{pmatrix} 0 & 1\\ 3 & 2 \end{pmatrix} $$
In [4]:
A = [[0, 3], [1, 2]]
B = [[0, 1], [3, 2]]
hawk_dove = nash.Game(A, B)
hawk_dove
Out[4]:
Consider two pigs. One dominant pig and one subservient pig. These pigs share a pen. There is a lever in the pen that delivers food but if either pig pushes the lever it will take them a little while to get to the food. If the dominant pig pushes the lever, the subservient pig has some time to eat most of the food before being pushed out of the way. If the subservient pig push the lever, the dominant pig will eat all the food. Finally if both pigs go to push the lever the subservient pig will be able to eat a third of the food.
This corresponds to:
$$ A = \begin{pmatrix} 4 & 2\\ 6 & 0 \end{pmatrix}\qquad B = \begin{pmatrix} 2 & 3\\ -1 & 0 \end{pmatrix} $$
In [5]:
A = [[4, 2], [6, 0]]
B = [[2, 3], [-1, 0]]
pigs = nash.Game(A, B)
pigs
Out[5]:
Consider two players who can choose to display a coin either Heads facing up or Tails facing up. If both players show the same face then player 1 wins, if not then player 2 wins.
This corresponds to:
$$ A = \begin{pmatrix} 1 & -1\\ -1 & 1 \end{pmatrix}\qquad B = \begin{pmatrix} -1 & 1\\ 1 & -1 \end{pmatrix} $$
In [6]:
A = [[1, -1], [-1, 1]]
B = [[-1, 1], [1, -1]]
matching_pennies = nash.Game(A, B)
matching_pennies
Out[6]:
In [7]:
A = [[1, -1], [-1, 1]]
matching_pennies = nash.Game(A)
matching_pennies
Out[7]: