Skip to content

Commit 0bf356c

Browse files
committed
Add clone argument to Graaskamp.
1 parent b5e8310 commit 0bf356c

File tree

4 files changed

+27
-15
lines changed

4 files changed

+27
-15
lines changed

axelrod/strategies/_strategies.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
from .axelrod_first import (
99
FirstByDavis,
1010
FirstByFeld,
11-
Graaskamp,
11+
FirstByGraaskamp,
1212
Grofman,
1313
Joss,
1414
Nydegger,
@@ -325,7 +325,7 @@
325325
GoByMajority40,
326326
GoByMajority5,
327327
Golden,
328-
Graaskamp,
328+
FirstByGraaskamp,
329329
SecondByGraaskampKatzen,
330330
Gradual,
331331
GradualKiller,

axelrod/strategies/axelrod_first.py

Lines changed: 21 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -250,25 +250,37 @@ def strategy(self, opponent: Player) -> Action:
250250
return random_choice(p)
251251

252252

253-
class Graaskamp(Player):
253+
class FirstByGraaskamp(Player):
254254
"""
255+
Submitted to Axelrod's first tournament by James Graaskamp..
255256
256-
This is one of the strategies from Robert Axelrod's first tournament and is
257-
described in the literature as:
257+
The description written in [Axelrod1980]_ is:
258+
259+
> "This rule plays tit for tat for 50 moves, defects on move 51, and then
260+
> plays 5 more moves of tit for tat. A check is then made to see if the player
261+
> seems to be RANDOM, in which case it defects from then on. A check is also
262+
> made to see if the other is TIT FOR TAT, ANALOGY (a program from the
263+
> preliminary tournament), and its own twin, in which case it plays tit for
264+
> tat. Otherwise it randomly defects every 5 to 15 moves, hoping that enough
265+
> trust has been built up so that the other player will not notice these
266+
> defections.:
267+
268+
This is implemented as:
258269
259270
1. Plays Tit For Tat for the first 50 rounds;
260271
2. Defects on round 51;
261272
3. Plays 5 further rounds of Tit For Tat;
262273
4. A check is then made to see if the opponent is playing randomly in which
263-
case it defects for the rest of the game;
274+
case it defects for the rest of the game, this is implemented with a chi
275+
squared test.
264276
5. The strategy also checks to see if the opponent is playing Tit For Tat or
265-
another strategy from a preliminary tournament called ‘Analogy’ If
277+
a clone of itself. If
266278
so it plays Tit For Tat. If not it cooperates and randomly defects every 5
267279
to 15 moves.
268280
269281
270282
Note that there is no information about 'Analogy' available thus Step 5 is
271-
not implemented fully.
283+
a "best possible" interpretation of the description in the paper.
272284
273285
This strategy came 9th in Axelrod’s original tournament.
274286
@@ -277,7 +289,7 @@ class Graaskamp(Player):
277289
- Graaskamp: [Axelrod1980]_
278290
"""
279291

280-
name = "Graaskamp"
292+
name = "First tournament by Graaskamp"
281293
classifier = {
282294
"memory_depth": float("inf"),
283295
"stochastic": True,
@@ -321,8 +333,8 @@ def strategy(self, opponent: Player) -> Action:
321333
if all(
322334
opponent.history[i] == self.history[i - 1]
323335
for i in range(1, len(self.history))
324-
):
325-
# Check if opponent plays Tit for Tat
336+
) or opponent.history == self.history:
337+
# Check if opponent plays Tit for Tat or a clone of itself.
326338
if opponent.history[-1] == D:
327339
return D
328340
return C

axelrod/tests/strategies/test_axelrod_first.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -144,10 +144,10 @@ def test_strategy(self):
144144
self.versus_test(axelrod.Defector(), expected_actions=actions)
145145

146146

147-
class TestGraaskamp(TestPlayer):
147+
class TestFirstByGraaskamp(TestPlayer):
148148

149-
name = "Graaskamp: 0.05"
150-
player = axelrod.Graaskamp
149+
name = "First tournament by Graaskamp: 0.05"
150+
player = axelrod.FirstByGraaskamp
151151
expected_classifier = {
152152
"memory_depth": float("inf"),
153153
"stochastic": True,

docs/reference/overview_of_strategies.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ An indication is given as to whether or not this strategy is implemented in the
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>`"
2626
"Davis", "Morton Davis", ":class:`Davis <axelrod.strategies.axelrod_first.FirstByDavis>`"
27-
"Graaskamp", "Jim Graaskamp", ":class:`Graaskamp <axelrod.strategies.axelrod_first.Graaskamp>`"
27+
"Graaskamp", "Jim Graaskamp", ":class:`Graaskamp <axelrod.strategies.axelrod_first.FirstByGraaskamp>`"
2828
"Downing", "Leslie Downing", ":class:`RevisedDowning <axelrod.strategies.axelrod_first.RevisedDowning>`"
2929
"Feld", "Scott Feld", ":class:`Feld <axelrod.strategies.axelrod_first.FirstByFeld>`"
3030
"Joss", "Johann Joss", ":class:`Joss <axelrod.strategies.axelrod_first.Joss>`"

0 commit comments

Comments
 (0)