Skip to content

Commit b5e8310

Browse files
committed
Modify name of Davis and Feld.
Also make minor docstring amendments. Also made some notes regarding Downing.
1 parent 7520eec commit b5e8310

File tree

4 files changed

+67
-23
lines changed

4 files changed

+67
-23
lines changed

axelrod/strategies/_strategies.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@
66
from .appeaser import Appeaser
77
from .averagecopier import AverageCopier, NiceAverageCopier
88
from .axelrod_first import (
9-
Davis,
10-
Feld,
9+
FirstByDavis,
10+
FirstByFeld,
1111
Graaskamp,
1212
Grofman,
1313
Joss,
@@ -280,7 +280,7 @@
280280
CyclerDDC,
281281
CyclerCCCDCD,
282282
Darwin,
283-
Davis,
283+
FirstByDavis,
284284
DBS,
285285
Defector,
286286
DefectorHunter,
@@ -303,7 +303,7 @@
303303
EvolvedLookerUp1_1_1,
304304
EvolvedLookerUp2_2_2,
305305
EvolvedHMM5,
306-
Feld,
306+
FirstByFeld,
307307
FirmButFair,
308308
FoolMeOnce,
309309
ForgetfulFoolMeOnce,

axelrod/strategies/axelrod_first.py

Lines changed: 55 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,16 @@
11
"""
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.
314
"""
415

516
import random
@@ -16,12 +27,14 @@
1627
C, D = Action.C, Action.D
1728

1829

19-
class Davis(Player):
30+
class FirstByDavis(Player):
2031
"""
2132
Submitted to Axelrod's first tournament by Morton Davis.
2233
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."
2538
2639
This strategy came 8th in Axelrod's original tournament.
2740
@@ -30,7 +43,7 @@ class Davis(Player):
3043
- Davis: [Axelrod1980]_
3144
"""
3245

33-
name = "Davis"
46+
name = "First tournament by Davis"
3447
classifier = {
3548
"memory_depth": float("inf"), # Long memory
3649
"stochastic": False,
@@ -56,18 +69,41 @@ def strategy(self, opponent: Player) -> Action:
5669
opponent ever plays D."""
5770
if len(self.history) < self._rounds_to_cooperate:
5871
return C
59-
if opponent.defections:
72+
if opponent.defections > 0:
6073
return D
6174
return C
6275

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.
6485
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
66101
the probability of cooperating given that they defected (:math:`p(C|D)`) or
67102
cooperated on the previous round (:math:`p(C|C)`). These probabilities are
68103
continuously updated during play and the strategy attempts to maximise the long
69104
term play. Note that the initial values are :math:`p(C|C)=p(C|D)=.5`.
70105
106+
# TODO: This paragraph is not correct (see note above)
71107
Downing is implemented as `RevisedDowning`. Apparently in the first tournament
72108
the strategy was implemented incorrectly and defected on the first two rounds.
73109
This can be controlled by setting `revised=True` to prevent the initial defections.
@@ -140,13 +176,21 @@ def strategy(self, opponent: Player) -> Action:
140176
return move
141177

142178

143-
class Feld(Player):
179+
class FirstByFeld(Player):
144180
"""
145181
Submitted to Axelrod's first tournament by Scott Feld.
146182
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+
147189
This strategy plays Tit For Tat, always defecting if the opponent defects but
148190
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.
150194
151195
This strategy came 11th in Axelrod's original tournament.
152196
@@ -155,7 +199,7 @@ class Feld(Player):
155199
- Feld: [Axelrod1980]_
156200
"""
157201

158-
name = "Feld"
202+
name = "First tournament by Feld"
159203
classifier = {
160204
"memory_depth": 200, # Varies actually, eventually becomes depth 1
161205
"stochastic": True,

axelrod/tests/strategies/test_axelrod_first.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,10 @@
77
C, D = axelrod.Action.C, axelrod.Action.D
88

99

10-
class TestDavis(TestPlayer):
10+
class TestFirstByDavis(TestPlayer):
1111

12-
name = "Davis: 10"
13-
player = axelrod.Davis
12+
name = "First tournament by Davis: 10"
13+
player = axelrod.FirstByDavis
1414
expected_classifier = {
1515
"memory_depth": float("inf"),
1616
"stochastic": False,
@@ -88,10 +88,10 @@ def test_not_revised(self):
8888
self.assertEqual(match.play(), [(D, C), (D, C)])
8989

9090

91-
class TestFeld(TestPlayer):
91+
class TestFristByFeld(TestPlayer):
9292

93-
name = "Feld: 1.0, 0.5, 200"
94-
player = axelrod.Feld
93+
name = "First tournament by Feld: 1.0, 0.5, 200"
94+
player = axelrod.FirstByFeld
9595
expected_classifier = {
9696
"memory_depth": 200,
9797
"stochastic": True,

docs/reference/overview_of_strategies.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,10 @@ An indication is given as to whether or not this strategy is implemented in the
2323
"Shubik", "Martin Shubik", ":class:`Shubik <axelrod.strategies.axelrod_first.Shubik>`"
2424
"Stein and Rapoport", "Stein and Anatol Rapoport", ":class:`SteinAndRapoport <axelrod.strategies.axelrod_first.SteinAndRapoport>`"
2525
"Grudger", "James W Friedman", ":class:`Grudger <axelrod.strategies.grudger.Grudger>`"
26-
"Davis", "Morton Davis", ":class:`Davis <axelrod.strategies.axelrod_first.Davis>`"
26+
"Davis", "Morton Davis", ":class:`Davis <axelrod.strategies.axelrod_first.FirstByDavis>`"
2727
"Graaskamp", "Jim Graaskamp", ":class:`Graaskamp <axelrod.strategies.axelrod_first.Graaskamp>`"
2828
"Downing", "Leslie Downing", ":class:`RevisedDowning <axelrod.strategies.axelrod_first.RevisedDowning>`"
29-
"Feld", "Scott Feld", ":class:`Feld <axelrod.strategies.axelrod_first.Feld>`"
29+
"Feld", "Scott Feld", ":class:`Feld <axelrod.strategies.axelrod_first.FirstByFeld>`"
3030
"Joss", "Johann Joss", ":class:`Joss <axelrod.strategies.axelrod_first.Joss>`"
3131
"Tullock", "Gordon Tullock", ":class:`Tullock <axelrod.strategies.axelrod_first.Tullock>`"
3232
"Unnamed Strategy", "Unknown", ":class:`UnnamedStrategy <axelrod.strategies.axelrod_first.UnnamedStrategy>`"

0 commit comments

Comments
 (0)