Skip to content

Commit 7587d7a

Browse files
committed
GradualKiller uses InitialTransformer decorator, typos
1 parent 8f64b6a commit 7587d7a

File tree

3 files changed

+19
-11
lines changed

3 files changed

+19
-11
lines changed

axelrod/strategies/gradualkiller.py

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,16 @@
11
from axelrod import Actions, Player, init_args
2-
C, D = Actions.C, Actions.D
2+
from axelrod.strategy_transformers import InitialTransformer
33

4+
C, D = Actions.C, Actions.D
45

6+
@InitialTransformer((D, D, D, D, D, C, C), name_prefix=None)
57
class GradualKiller(Player):
68
"""
79
It begins by defecting in the first five moves, then cooperates two times.
810
It then defects all the time if the opponent has defected in move 6 and 7,
911
else cooperates all the time.
12+
Initially designed to stop Gradual from defeating TitForTat in a 3 Player
13+
tournament.
1014
1115
Names
1216
@@ -27,11 +31,16 @@ class GradualKiller(Player):
2731

2832
def strategy(self, opponent):
2933
"""This is the actual strategy"""
30-
# First seven moves
31-
firstseven = [D, D, D, D, D, C, C]
32-
if len(self.history) < 7:
33-
return firstseven[len(self.history)]
34-
# React to the opponent's 6th and 7th moves
35-
elif opponent.history[5:7] == [D, D]:
36-
return D
34+
# # First seven moves
35+
# firstseven = [D, D, D, D, D, C, C]
36+
# if len(self.history) < 7:
37+
# return firstseven[len(self.history)]
38+
# # React to the opponent's 6th and 7th moves
39+
# elif opponent.history[5:7] == [D, D]:
40+
# return D
41+
# return C
42+
43+
if len(self.history) >= 7:
44+
if opponent.history[5:7] == [D, D]:
45+
return D
3746
return C

axelrod/strategies/grudger.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -176,12 +176,13 @@ def reset(self):
176176

177177
class GrudgerAlternator(Player):
178178
"""
179-
A player starts by cooperating until the first opponents defenction,
179+
A player starts by cooperating until the first opponents defection,
180180
then alternates D-C.
181181
182182
Names:
183183
184184
- c_then_per_dc: [PRISON1998]_
185+
- GrudgerAlternator
185186
"""
186187

187188
name = 'GrudgerAlternator'

axelrod/tests/unit/test_grudger.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -229,8 +229,6 @@ def test_starategy_random_number_rounds(self):
229229
self.responses_test(my_hist, opp_hist, expected_response)
230230

231231

232-
233-
234232
class TestEasyGo(TestPlayer):
235233

236234
name = "EasyGo"

0 commit comments

Comments
 (0)