The Iterated Prisoner’s Dilemma is a classic problem in game theory, and I decided to make a “competition” for it. (the winner gets nothing) Posting early because blystii guessed a number…
Rules
- One submission per user. I won’t include second submissions.
- Strategies must only use built-in Python features, plus the
randommodule, and must not have any side effects. - Strategies may be at most 256 LLOC (Logical Lines of Code).
- Strategies must terminate. You may use a
while Trueor any other way to loop indefinitely, so long as it is guaranteed to terminate. - Strategy names must be unique. If they are not unique, the name of the submitter will be prepended.
- The deadline for submissions is December 31st, 23:59 UTC. Results should be announced by January 2nd, who knows if I’ll remember.
Making a submission
Format for submitting
Name: your name here
# your code here
Example submission
Name: tit_for_tat
def tit_for_tat(ours, theirs):
return theirs[-1] if theirs else True
Another example
Name: random_choice
def random_choice(ours, theirs):
return random.choice([True, False])
How to code a strategy
A strategy is really just a Python function taking a list of its own moves, and its opponent’s moves. Returning True means the strategy wishes to cooperate, returning False means it wishes to defect. Note that the lists of moves are not updated until both moves are made.
How winners will be decided
Temptation (T) is 5.
Reward (R) is 3.
Punishment (P) is 1.
Sucker (S) is 0.
This satisfies the two rules for the iterated prisoner’s dilemma:
- T > R > P > S
- 2R > T + S
Visually, this means:
| Payoff Matrix | You Cooperate | You Defect |
|---|---|---|
| They Cooperate | You get 3, they get 3 | You get 5, they get 0 |
| They Defect | They get 5, you get 0 | You get 1, they get 1 |
The winner is whoever gets the most points across all matchups.
Strategies will be faced off against each other, round-robin style.
Notes
- “Counter strategies”, those which exist soley to perform well against certain strategies, are strongly discouraged.
