File Exchange

image thumbnail

Iterated Prisoner's Dilemma

version (9.11 KB) by Zachary Danziger
The iterated prisoner's dilemma game for multiple players and multiple submissions per player.


Updated 14 May 2010

View License

The iterated prisoner's dilemma (IPD) game has long been studied in game theory, economics, programming, decision theory and other fields. It is a 2-player scenario where each player must decide to either 'cooperate' or 'defect' in a sequence of games, and their respective choices determine the relative success or failure of each player. Will you cooperate with your opponent or look to steal all the points for yourself?

This code runs a tournament among two or more players. Each player may submit as many "personalities" as they wish. Each personality submitted by each player plays the IPD game against all personalities submitted by all other players. Results are then plotted and outputted.

An example has already been set up in this submission among 3 example players and a number of simple sample personalties for each player. To create your own players and personalites, simply swap out the player directories and example functions. To run the example,
>> IPDshell

For more detail, specific rules and instructions for creating your own personalities,
>> help IPDshell

For more information on the prisoner's dilemma see:

Cite As

Zachary Danziger (2021). Iterated Prisoner's Dilemma (, MATLAB Central File Exchange. Retrieved .

Comments and Ratings (5)

Ani Asoyan

I want to build a finite prisoner's dilemma game, where 2 players have their payoff function and every period make choices based on their payoff maximization. current choices affect payoff function and every period they change their choice based on maximization. How can I do that? please help.
for more detail please see my comment on the question :

Georgios Charalambous

I also have the same issue.

I have a mac aswell and when I try to compile I get an error related to the addpath function.
Did anyone solve this problem?

martina testori

I have a problem with this code.
I have a mac and when I try to compile I get an error related to the addpath function.
Do you know how to solve this problem?


Luci Tanasa

MATLAB Release Compatibility
Created with R2009a
Compatible with any release
Platform Compatibility
Windows macOS Linux

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!