Skip to content

Commit 6449253

Browse files
Merge pull request #1290 from Axelrod-Python/1285
Update FirstBy Downing for #1285
2 parents 09b776a + 45bc090 commit 6449253

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

axelrod/strategies/axelrod_first.py

+8-6
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@ def strategy(self, opponent: Player) -> Action:
7373
return D
7474
return C
7575

76+
7677
class FirstByDowning(Player):
7778
"""
7879
Submitted to Axelrod's first tournament by Downing
@@ -257,19 +258,20 @@ def strategy(self, opponent: Player) -> Action:
257258
self.number_opponent_cooperations_in_response_to_C += 1
258259
return D
259260

260-
261261
if self.history[-2] == C and opponent.history[-1] == C:
262262
self.number_opponent_cooperations_in_response_to_C += 1
263263
if self.history[-2] == D and opponent.history[-1] == C:
264264
self.number_opponent_cooperations_in_response_to_D += 1
265265

266+
# Adding 1 to cooperations for assumption that first opponent move
267+
# being a response to a cooperation. See docstring for more
268+
# information.
266269
alpha = (self.number_opponent_cooperations_in_response_to_C /
267-
(self.cooperations + 1)) # Adding 1 to count for assumption
268-
# that first opponent move being a
269-
# response to a cooperation. See
270-
# docstring for more information.
270+
(self.cooperations + 1))
271+
# Adding 2 to defections on the assumption that the first two
272+
# moves are defections, which may not be true in a noisy match
271273
beta = (self.number_opponent_cooperations_in_response_to_D /
272-
(self.defections))
274+
max(self.defections, 2))
273275

274276
R, P, S, T = self.match_attributes["game"].RPST()
275277
expected_value_of_cooperating = alpha * R + (1 - alpha) * S

0 commit comments

Comments
 (0)