Skip to content

Update FirstBy Downing for #1285 #1290

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 4, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 8 additions & 6 deletions axelrod/strategies/axelrod_first.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ def strategy(self, opponent: Player) -> Action:
return D
return C


class FirstByDowning(Player):
"""
Submitted to Axelrod's first tournament by Downing
Expand Down Expand Up @@ -257,19 +258,20 @@ def strategy(self, opponent: Player) -> Action:
self.number_opponent_cooperations_in_response_to_C += 1
return D


if self.history[-2] == C and opponent.history[-1] == C:
self.number_opponent_cooperations_in_response_to_C += 1
if self.history[-2] == D and opponent.history[-1] == C:
self.number_opponent_cooperations_in_response_to_D += 1

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

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