Each vertical bar represents one round in the iterated Prisoners Dilemma.
Its color tells you the result of the round:
Your total score for the 120-round game is shown at top left.
The parenthetical shows you what agent acted as your "opponent" and its total score. Remember you aren't trying to beat the opponent, just trying to maximize your own score.
Its color tells you the result of the round:
Result | You scored | Opponent scored | |
---|---|---|---|
|
Mutual cooperation | 3 | 3 |
|
Mutual defection | 1 | 1 |
|
Greed | 5 | 0 |
|
Sucker | 0 | 5 |
... or upload your code (accepts Java or Python)
How to play
The game is 120 rounds. Each round you pick a row in this table, and the other player picks a column:
Cooperate | Defect | |
Cooperate | 3 (3) | 0 (5) |
Defect | 5 (0) | 1 (1) |
You are awarded the points in bold, and the other player gets the points in parentheses.
Your goal is to get as many points as you can. The other player's score doesn't affect you, except that the other player will strategize to get as many points as possible too.
Please see our Overview for more information.
API
The agent (
self
) has an actor
field. Make your move by calling one of these functions on the actor:actor.cooperate()
actor.defect()
actor.act(action)
where action is COOPERATE
or DEFECT
Those functions each return an object
result
for the round, with these fields:myAction
- action you pickedmyPayoff
- points you gototherPlayerAction
- action opponent pickedotherPlayerPayoff
- points opponent gotSee full API for more info.
Examples
Our present Python example is Tit For Tat, a short routine which cooperates on the first move, and thereafter does what the opponent did on the previous move.
If Tit For Tat source code is not already visible in the editor, click here to load it.