Prisoner’s Dilemma

A 2-player vintage Prisoner’s Dilemma game (https://en.wikipedia.org/wiki/Prisoner%27s_dilemma).

This is a classic paradox in game theory where a stable outcome (i.e., a Nash equilibrium) is worse off for both players.

class imperfecto.games.prisoner_dilemma.PRISONER_DILEMMA_ACTIONS(value)[source]

Bases: imperfecto.misc.utils.lessVerboseEnum, enum.IntEnum

Available actions in the Prisoner’s Dilemma game.

SNITCH = 0
SILENCE = 1
class imperfecto.games.prisoner_dilemma.PrisonerDilemmaGame(players)[source]

Bases: imperfecto.games.game.NormalFormGame

A 2-player vintage classical Prisoner’s Dilemma game. (https://en.wikipedia.org/wiki/Prisoner%27s_dilemma)

Two players are crime partners in a robbery. They were arrested by the police but the police has no evidence to convict them. So the police commisioner sits each player on a separate room and offers them a deal. If one player confesses and snitches against the other, the confessor will go free and their partner will receive 3 years. If both players stay silent, they will serve 1 year for another mirror crime that the police was able to catch. However, if both of them betray each other, they will both serve 2 years.

Payoff:
  • If both silence, get 1 year each.

  • If both betray, get 2 years each.

  • If one silence and one snitches, the snitch goes free and the silent partner gets 3 years.

Nash Equilibria:

The only Nash Equilibrium is when both players snitch. (payoff = -2 for both)

actions

alias of imperfecto.games.prisoner_dilemma.PRISONER_DILEMMA_ACTIONS

n_players: int = 2
get_payoffs(history)[source]

Return the payoff for each player at the current node.

Note

history must be a terminal node.

Parameters

history (Sequence[PRISONER_DILEMMA_ACTIONS]) – The history of the game.

Return type

Sequence[float]

Returns

The payoffs of the players at the end of the game.