1
1
"""
2
- Additional strategies from Axelrod's first tournament.
2
+ Strategies from Axelrod's first tournament. All strategies in this module are
3
+ prefixed by `FirstBy` to indicate that they were submitted in Axelrod's First
4
+ tournament by the given author.
5
+
6
+ Note that in these strategies are implemented from the descriptions presented
7
+ in:
8
+
9
+ Axelrod, R. (1980). Effective Choice in the Prisoner’s Dilemma.
10
+ Journal of Conflict Resolution, 24(1), 3–25.
11
+
12
+ These descriptions are not always clear and/or precise and when assumptions have
13
+ been made they are explained in the strategy docstrings.
3
14
"""
4
15
5
16
import random
16
27
C , D = Action .C , Action .D
17
28
18
29
19
- class Davis (Player ):
30
+ class FirstByDavis (Player ):
20
31
"""
21
32
Submitted to Axelrod's first tournament by Morton Davis.
22
33
23
- A player starts by cooperating for 10 rounds then plays Grudger,
24
- defecting if at any point the opponent has defected.
34
+ The description written in [Axelrod1980]_ is:
35
+
36
+ > "A player starts by cooperating for 10 rounds then plays Grudger,
37
+ > defecting if at any point the opponent has defected."
25
38
26
39
This strategy came 8th in Axelrod's original tournament.
27
40
@@ -30,7 +43,7 @@ class Davis(Player):
30
43
- Davis: [Axelrod1980]_
31
44
"""
32
45
33
- name = "Davis"
46
+ name = "First tournament by Davis"
34
47
classifier = {
35
48
"memory_depth" : float ("inf" ), # Long memory
36
49
"stochastic" : False ,
@@ -56,18 +69,41 @@ def strategy(self, opponent: Player) -> Action:
56
69
opponent ever plays D."""
57
70
if len (self .history ) < self ._rounds_to_cooperate :
58
71
return C
59
- if opponent .defections :
72
+ if opponent .defections > 0 :
60
73
return D
61
74
return C
62
75
63
-
76
+ # TODO Split this in to ttwo strategies, it's not clear to me from the internet
77
+ # sources that the first implentation was buggy as opposed to just "poorly
78
+ # thought out". The flaw is actually clearly described in the paper's
79
+ # description: "Initially, they are both assumed to be .5, which amounts to the
80
+ # pessimistic assumption that the other player is not responsive"
81
+ # The revised version should be put in it's own module.
82
+ # I also do not understand where the decision rules come from.
83
+ # Need to read https://journals.sagepub.com/doi/10.1177/003755007500600402 to
84
+ # gain understanding of decision rule.
64
85
class RevisedDowning (Player ):
65
- """This strategy attempts to estimate the next move of the opponent by estimating
86
+ """
87
+ Submitted to Axelrod's first tournament by Downing
88
+
89
+ The description written in [Axelrod1980]_ is:
90
+
91
+ > "This rule selects its choice to maximize its own long- term expected payoff on
92
+ > the assumption that the other rule cooperates with a fixed probability which
93
+ > depends only on whether the other player cooperated or defected on the previous
94
+ > move. These two probabilities estimates are con- tinuously updated as the game
95
+ > progresses. Initially, they are both assumed to be .5, which amounts to the
96
+ > pessimistic assumption that the other player is not responsive. This rule is
97
+ > based on an outcome maximization interpretation of human performances proposed
98
+ > by Downing (1975)."
99
+
100
+ This strategy attempts to estimate the next move of the opponent by estimating
66
101
the probability of cooperating given that they defected (:math:`p(C|D)`) or
67
102
cooperated on the previous round (:math:`p(C|C)`). These probabilities are
68
103
continuously updated during play and the strategy attempts to maximise the long
69
104
term play. Note that the initial values are :math:`p(C|C)=p(C|D)=.5`.
70
105
106
+ # TODO: This paragraph is not correct (see note above)
71
107
Downing is implemented as `RevisedDowning`. Apparently in the first tournament
72
108
the strategy was implemented incorrectly and defected on the first two rounds.
73
109
This can be controlled by setting `revised=True` to prevent the initial defections.
@@ -140,13 +176,21 @@ def strategy(self, opponent: Player) -> Action:
140
176
return move
141
177
142
178
143
- class Feld (Player ):
179
+ class FirstByFeld (Player ):
144
180
"""
145
181
Submitted to Axelrod's first tournament by Scott Feld.
146
182
183
+ The description written in [Axelrod1980]_ is:
184
+
185
+ > "This rule starts with tit for tat and gradually lowers its probability of
186
+ > cooperation following the other's cooperation to .5 by the two hundredth
187
+ > move. It always defects after a defection by the other."
188
+
147
189
This strategy plays Tit For Tat, always defecting if the opponent defects but
148
190
cooperating when the opponent cooperates with a gradually decreasing probability
149
- until it is only .5.
191
+ until it is only .5. Note that the description does not clearly indicate how
192
+ the cooperation probability should drop, this implements a linear decreasing
193
+ function.
150
194
151
195
This strategy came 11th in Axelrod's original tournament.
152
196
@@ -155,7 +199,7 @@ class Feld(Player):
155
199
- Feld: [Axelrod1980]_
156
200
"""
157
201
158
- name = "Feld"
202
+ name = "First tournament by Feld"
159
203
classifier = {
160
204
"memory_depth" : 200 , # Varies actually, eventually becomes depth 1
161
205
"stochastic" : True ,
0 commit comments