Skip to content

Commit 529e1bb

Browse files
authored
Merge pull request #1113 from Axelrod-Python/minor-bug-in-gladstein
Fix a small bug in Gladstein.
2 parents bb951aa + 027d7df commit 529e1bb

File tree

2 files changed

+9
-4
lines changed

2 files changed

+9
-4
lines changed

axelrod/strategies/axelrod_second.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,7 @@ def strategy(self, opponent: Player) -> Action:
197197
return C
198198
# Cooperate as long as the cooperation ratio is below 0.5
199199
cooperation_ratio = self.cooperations / len(self.history)
200-
if cooperation_ratio >= 0.5:
200+
if cooperation_ratio > 0.5:
201201
return D
202202
return C
203203
else:

axelrod/tests/strategies/test_axelrod_second.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -138,8 +138,8 @@ def test_strategy(self):
138138
self.versus_test(axelrod.Alternator(), expected_actions=actions,
139139
attrs={'patsy': False})
140140

141-
# Cooperation ratio will always be less than or equal to 0.5
142-
actions = [(D, C), (C, C), (D, C), (C, C), (D, C)]
141+
# Cooperation ratio will always be less than 0.5
142+
actions = [(D, C), (C, C), (C, C), (D, C), (C, C)]
143143
self.versus_test(axelrod.Cooperator(), expected_actions=actions,
144144
attrs={'patsy': True})
145145

@@ -150,6 +150,11 @@ def test_strategy(self):
150150

151151
# Ratio is 1/3 when MockPlayer defected for the first time.
152152
opponent = axelrod.MockPlayer(actions=[C, C, C, D, D])
153-
actions = [(D, C), (C, C), (D, C), (C, D), (C, D)]
153+
actions = [(D, C), (C, C), (C, C), (D, D), (C, D)]
154+
self.versus_test(opponent, expected_actions=actions,
155+
attrs={'patsy': False})
156+
157+
opponent = axelrod.AntiTitForTat()
158+
actions = [(D, C), (C, C), (C, D), (C, D), (D, D)]
154159
self.versus_test(opponent, expected_actions=actions,
155160
attrs={'patsy': False})

0 commit comments

Comments
 (0)