Skip to content

Commit 6e6a573

Browse files
committed
Make minor modifications suggested by @marcharper.
1 parent ce1d6e6 commit 6e6a573

File tree

5 files changed

+96
-90
lines changed

5 files changed

+96
-90
lines changed

axelrod/strategies/axelrod_first.py

Lines changed: 31 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ class FirstByDavis(Player):
4343
- Davis: [Axelrod1980]_
4444
"""
4545

46-
name = "First tournament by Davis"
46+
name = "First by Davis"
4747
classifier = {
4848
"memory_depth": float("inf"), # Long memory
4949
"stochastic": False,
@@ -69,7 +69,7 @@ def strategy(self, opponent: Player) -> Action:
6969
opponent ever plays D."""
7070
if len(self.history) < self._rounds_to_cooperate:
7171
return C
72-
if opponent.defections > 0:
72+
if opponent.defections > 0: # Implement Grudger
7373
return D
7474
return C
7575

@@ -97,7 +97,7 @@ class FirstByDowning(Player):
9797
> "[...] In these strategies, O's [the opponent's] response on trial N is in
9898
some way dependent or contingent on S's [the subject's] response on trial N-
9999
1. All varieties of these lag-one matching strategies can be defined by two
100-
parameters: the conditional probability that O will choose C folloging C by
100+
parameters: the conditional probability that O will choose C following C by
101101
S, P(C_o | C_s) and the conditional probability that O will choose C
102102
following D by S, P(C_o, D_s)."
103103
@@ -120,7 +120,7 @@ class FirstByDowning(Player):
120120
To understand the particular mechanism that describes the strategy S, we
121121
refer to Appendix A of the paper on page 389.
122122
123-
The state goal of the strategy is to maximize (using the notation of the
123+
The stated goal of the strategy is to maximize (using the notation of the
124124
paper):
125125
126126
EV_TOT = #CC(EV_CC) + #CD(EV_CD) + #DC(EV_DC) + #DD(EV_DD)
@@ -130,7 +130,7 @@ class FirstByDowning(Player):
130130
131131
On the second page of the appendix, figure 4 (page 390) supposedly
132132
identifies an expression for EV_TOT however it is not clear how some of the
133-
steps are carried out. To the best guess, it seems like an asymptotic
133+
steps are carried out. It seems like an asymptotic
134134
argument is being used. Furthermore, a specific term is made to disappear in
135135
the case of T - R = P - S (which is not the case for the standard
136136
(R, P, S, T) = (3, 1, 0, 5)):
@@ -147,8 +147,8 @@ class FirstByDowning(Player):
147147
148148
1. On any given turn, the strategy will estimate alpha = P(C_o | C_s) and
149149
beta = P(C_o | D_s).
150-
2. The stragy will calculate the expected utility of always playing C OR
151-
always playing D against the estimage probabilities. This corresponds to:
150+
2. The strategy will calculate the expected utility of always playing C OR
151+
always playing D against the estimated probabilities. This corresponds to:
152152
153153
a. In the case of the player always cooperating:
154154
@@ -186,7 +186,8 @@ class FirstByDowning(Player):
186186
However there is a presentation available at
187187
http://www.sci.brooklyn.cuny.edu/~sklar/teaching/f05/alife/notes/azhar-ipd-Oct19th.pdf
188188
That clearly states that Downing defected in the first two rounds, thus this
189-
is assumed to be the behaviour.
189+
is assumed to be the behaviour. Interestingly, in future tournaments this
190+
strategy was revised to not defect on the opening two rounds.
190191
191192
Note that response to the first round allows us to estimate
192193
beta = P(C_o | D_s) and we will use the opening play of the player to
@@ -201,7 +202,7 @@ class FirstByDowning(Player):
201202
- Revised Downing: [Axelrod1980]_
202203
"""
203204

204-
name = "First tournament by Downing"
205+
name = "First by Downing"
205206

206207
classifier = {
207208
"memory_depth": float("inf"),
@@ -273,7 +274,7 @@ class FirstByFeld(Player):
273274
- Feld: [Axelrod1980]_
274275
"""
275276

276-
name = "First tournament by Feld"
277+
name = "First by Feld"
277278
classifier = {
278279
"memory_depth": 200, # Varies actually, eventually becomes depth 1
279280
"stochastic": True,
@@ -326,7 +327,7 @@ def strategy(self, opponent: Player) -> Action:
326327

327328
class FirstByGraaskamp(Player):
328329
"""
329-
Submitted to Axelrod's first tournament by James Graaskamp..
330+
Submitted to Axelrod's first tournament by James Graaskamp.
330331
331332
The description written in [Axelrod1980]_ is:
332333
@@ -354,6 +355,9 @@ class FirstByGraaskamp(Player):
354355
355356
Note that there is no information about 'Analogy' available thus Step 5 is
356357
a "best possible" interpretation of the description in the paper.
358+
Furthermore the test for the clone is implemented as checking that both
359+
players have played the same moves for the entire game, this is unlikely to
360+
be the original approach but no further details are available.
357361
358362
This strategy came 9th in Axelrod’s original tournament.
359363
@@ -362,7 +366,7 @@ class FirstByGraaskamp(Player):
362366
- Graaskamp: [Axelrod1980]_
363367
"""
364368

365-
name = "First tournament by Graaskamp"
369+
name = "First by Graaskamp"
366370
classifier = {
367371
"memory_depth": float("inf"),
368372
"stochastic": True,
@@ -438,7 +442,7 @@ class FirstByGrofman(Player):
438442
- Grofman: [Axelrod1980]_
439443
"""
440444

441-
name = "First tournament by Grofman"
445+
name = "First by Grofman"
442446
classifier = {
443447
"memory_depth": 1,
444448
"stochastic": True,
@@ -471,7 +475,7 @@ class FirstByJoss(MemoryOnePlayer):
471475
- Hard Joss: [Stewart2012]_
472476
"""
473477

474-
name = "First tournament by Joss"
478+
name = "First by Joss"
475479

476480
def __init__(self, p: float = 0.9) -> None:
477481
"""
@@ -539,7 +543,7 @@ class FirstByNydegger(Player):
539543
- Nydegger: [Axelrod1980]_
540544
"""
541545

542-
name = "First tournament by Nydegger"
546+
name = "First by Nydegger"
543547
classifier = {
544548
"memory_depth": 3,
545549
"stochastic": False,
@@ -604,7 +608,7 @@ class FirstByShubik(Player):
604608
defection on the turn where it starts to cooperate once more. In Shubik
605609
(1970) the strategy is described as:
606610
607-
> "I will play my move 1 to begin with and will continue to do so, so long
611+
> "I will play my move 1 to begin with and will continue to do so, so long
608612
> as my information shows that the other player has chosen his move 1. If my
609613
> information tells me he has used move 2, then I will use move 2 for the
610614
> immediate k subsequent periods, after which I will resume using move 1. If
@@ -619,12 +623,14 @@ class FirstByShubik(Player):
619623
defects for k rounds. After k rounds it starts cooperating again and
620624
increments the value of k if the opponent defects again.
621625
626+
This strategy came 5th in Axelrod's original tournament.
627+
622628
Names:
623629
624630
- Shubik: [Axelrod1980]_
625631
"""
626632

627-
name = "First tournament by Shubik"
633+
name = "First by Shubik"
628634
classifier = {
629635
"memory_depth": float("inf"),
630636
"stochastic": False,
@@ -695,9 +701,9 @@ class FirstByTullock(Player):
695701
- Tullock: [Axelrod1980]_
696702
"""
697703

698-
name = "First tournament by Tullock"
704+
name = "First by Tullock"
699705
classifier = {
700-
"memory_depth": 11,
706+
"memory_depth": float("inf"),
701707
"stochastic": True,
702708
"makes_use_of": set(),
703709
"long_run_time": False,
@@ -706,16 +712,16 @@ class FirstByTullock(Player):
706712
"manipulates_state": False,
707713
}
708714

709-
def __init__(self, rounds_to_cooperate: int = 11) -> None:
715+
def __init__(self) -> None:
710716
"""
711717
Parameters
712718
----------
713719
rounds_to_cooperate: int
714720
The number of rounds to cooperate initially
715721
"""
716722
super().__init__()
717-
self._rounds_to_cooperate = rounds_to_cooperate
718-
self.memory_depth = rounds_to_cooperate
723+
self._rounds_to_cooperate = 11
724+
self.memory_depth = self._rounds_to_cooperate
719725

720726
def strategy(self, opponent: Player) -> Action:
721727
if len(self.history) < self._rounds_to_cooperate:
@@ -751,7 +757,7 @@ class FirstByAnonymous(Player):
751757
- (Name withheld): [Axelrod1980]_
752758
"""
753759

754-
name = "First tournament by Anonymous"
760+
name = "First by Anonymous"
755761
classifier = {
756762
"memory_depth": 0,
757763
"stochastic": True,
@@ -796,7 +802,7 @@ class FirstBySteinAndRapoport(Player):
796802
- SteinAndRapoport: [Axelrod1980]_
797803
"""
798804

799-
name = "First tournament by Stein and Rapoport"
805+
name = "First by Stein and Rapoport"
800806
classifier = {
801807
"memory_depth": float("inf"),
802808
"stochastic": False,
@@ -884,7 +890,7 @@ class FirstByTidemanAndChieruzzi(Player):
884890
- TidemanAndChieruzzi: [Axelrod1980]_
885891
"""
886892

887-
name = "First tournament by Tideman and Chieruzzi"
893+
name = "First by Tideman and Chieruzzi"
888894
classifier = {
889895
"memory_depth": float("inf"),
890896
"stochastic": False,

0 commit comments

Comments
 (0)