"Agent-based Axelrod tournament."

The applet requires Java 1.4.1 or higher. It will not run on Windows 95 or Mac OS 8 or 9. Mac users must have OS X 10.2.6 or higher and use a browser that supports Java 1.4. (Safari works, IE does not. Mac OS X comes with Safari. Open Safari and set it as your default web browser under Safari/Preferences/General.) On other operating systems, you may obtain the latest Java plugin from Sun's Java site.

An introduction to the model and a second presentation using the ODD protocol.

WHAT IS IT?

This project simulates a simplification of the Axelrod Tournament, where sixteen agents, each endowed with a given strategy, play repeatedly against each other the Prisoner Dilemma game.

HOW IT WORKS

The tournaments consists of matches between agents that play repeatedly the Prisoner Dilemma. Each player has a single match against each other, where the Prisoner Dilemma is repeated betwwen 1 and 200 times. At the end of the tournament it is shown the average payoff each player got each iteration of the game.
We have developed the possibility to choose between three different 'worlds' that differ depending on the distribution of the eight different strategies among the players; moreover there is the possibility to choose the number of repetitions the agents play the Prisoner Dilemma.

HOW TO USE IT

Click the setup button to set up the players.
Choose with the slider 'world' the world you want to run the simulation in: with 'Baseline' you are choosing a world with a couple of agents endowed with the same strategy; with 'Cooperative' you are building a setting with 9 players that play always C and 7 endowed with the remaining strategies; with 'Selfish' you have 9 players that choose always D and 7 that are endowed with the remaining strategies.
Set also the number of repetitions of the Prisoner Dilemma.
Click 'Start-meeting' to run the tournament.

THINGS TO TRY

Manipulating the slider you can see how the distribution of the strategies among the players affect the average payoff each player gets.
Also trying to change the number of iterations of the Prisoner Dilemma is a nice experiment, because with few iterations random behaviours affect consistently the average payoffs.

EXTENDING THE MODEL

There are two possible extensions of the model:
-introducing new and more complex strategies;
-trying to developing evolutionary behaviours, other than Tit-For-Tat and similar ones, namely strategies that are not 'fixed', but that change over time depending on what other players do

CREDITS AND REFERENCES

-Effective choice in the prisoner's dilemma, R Axelrod - Journal of Conflict Resolution, 1980
-More effective choice in the prisoner's dilemma, R Axelrod - Journal of Conflict Resolution, 1980

PROCEDURES

```globals[currentpartner]
breed[players player]
players-own[payoff defect? partner_defected? partner_defected_before?]

to setup
ca
set-default-shape players "person"
create-players 16
ask players [set color gray set ycor min-pycor set xcor ((world-width / 17 * (who + 1)) + min-pxcor) set heading 0 set size 1 set payoff 0 set defect? false set partner_defected? [false false false false false false false false false false false false false false false false] set partner_defected_before? [false false false false false false false false false false false false false false false false]]
end

to start-meetings
let i 0
while [i < iterations]
[
let partner [who] of other players
while [length partner > 0]
[set currentpartner first partner
set partner but-first partner
if [who] of player currentpartner > [who] of self

[choose_action
get_payoff
set partner_defected_before? replace-item currentpartner partner_defected_before? item currentpartner partner_defected?
set partner_defected? replace-item currentpartner partner_defected? [defect?] of player currentpartner
[
set partner_defected_before? replace-item [who] of myself partner_defected_before? item [who] of myself partner_defected?
set partner_defected? replace-item [who] of myself partner_defected? [defect?] of myself
]
]

]

]
fd (payoff / (15 * (i + 1)) - ycor)
set label precision (payoff / (15 * (i + 1))) 2
]
wait (1 / (i + 1))
set i i + 1
]
end

to choose_action
if world = "Baseline"
[
if who = 0 [cooperate]
if who = 1 [defect]
if who = 2 [tit_for_tat]
if who = 3 [tit_for_two_tat]
if who = 4 [two_tit_for_tat]
if who = 5 [random1]
if who = 6 [random2]
if who = 7 [random3]
if who = 8 [cooperate]
if who = 9 [defect]
if who = 10 [tit_for_tat]
if who = 11 [tit_for_two_tat]
if who = 12 [two_tit_for_tat]
if who = 13 [random1]
if who = 14 [random2]
if who = 15 [random3]
]
if world = "Cooperative"
[
if who = 0 [cooperate]
if who = 1 [defect]
if who = 2 [tit_for_tat]
if who = 3 [tit_for_two_tat]
if who = 4 [two_tit_for_tat]
if who = 5 [random1]
if who = 6 [random2]
if who = 7 [random3]
if (who = 8 or who = 9 or who = 10 or who = 11 or who = 12 or who = 13 or who = 14 or who = 15) [cooperate]
]
if world = "Selfish"
[
if who = 0 [cooperate]
if who = 1 [defect]
if who = 2 [tit_for_tat]
if who = 3 [tit_for_two_tat]
if who = 4 [two_tit_for_tat]
if who = 5 [random1]
if who = 6 [random2]
if who = 7 [random3]
if (who = 8 or who = 9 or who = 10 or who = 11 or who = 12 or who = 13 or who = 14 or who = 15) [defect]
]
end

to cooperate
set defect? false
set color red
end

to defect
set defect? true
set color blue
end

to tit_for_tat
ifelse [who] of self != currentpartner
[
ifelse item currentpartner partner_defected?
[set defect? true]
[set defect? false]]
[

ifelse item [who] of myself partner_defected?
[set defect? true]
[set defect? false]]
set color yellow
end

to tit_for_two_tat
ifelse [who] of self != currentpartner
[ifelse (item currentpartner partner_defected? and item currentpartner partner_defected_before?)
[set defect? true]
[set defect? false]]
[ifelse (item [who] of myself partner_defected? and item [who] of myself partner_defected_before?)
[set defect? true]
[set defect? false]]
set color green
end

to two_tit_for_tat
ifelse [who] of self != currentpartner
[ifelse (item currentpartner partner_defected? or item currentpartner partner_defected_before?)
[set defect? true]
[set defect? false]]
[ifelse (item [who] of myself partner_defected? or item [who] of myself partner_defected_before?)
[set defect? true]
[set defect? false]]
set color violet
end

to random1
ifelse random 2 = 0
[set defect? true]
[set defect? false]
set color white
end

to random2
ifelse random 10 < 8
[set defect? false]
[set defect? true]
set color orange
end

to random3
ifelse random 10 < 8
[set defect? true]
[set defect? false]
set color brown
end

to get_payoff
ifelse [who] of self != currentpartner
[ifelse [defect?] of player currentpartner
[
ifelse defect?
[set payoff payoff + 1]
[set payoff payoff + 0]
]
[
ifelse defect?
[set payoff payoff + 5]
[set payoff payoff + 3]]
]
[ifelse [defect?] of myself
[
ifelse defect?
[set payoff payoff + 1]
[set payoff payoff + 0]
]
[
ifelse defect?
[set payoff payoff + 5]
[set payoff payoff + 3]]
]
end

```