-
Notifications
You must be signed in to change notification settings - Fork 268
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
Implement Getzler, K35R from Axelrod's second. #1151
Conversation
axelrod/strategies/axelrod_second.py
Outdated
if not opponent.history: | ||
return C | ||
|
||
self.flack += 1 if opponent.history[-1]==D else 0 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
opponent.history[-1] == D else 0
(PEP8: spaces around the ==
)
axelrod/strategies/axelrod_second.py
Outdated
|
||
def __init__(self) -> None: | ||
super().__init__() | ||
self.flack = 0 # The relative untrustworthiness of opponent |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The type checker is falling over on travis because it sees that self.flack
is an int and then becomes a float. Change this to be self.flack = 0.0
fixes the issue (as it's initialised as a float). 👍
Logic looks good to me 👍 |
axelrod/strategies/axelrod_second.py
Outdated
self.flack += 1 if opponent.history[-1] == D else 0 | ||
self.flack *= 0.5 # Defections have half-life of one round | ||
|
||
return random_choice(1.0-self.flack) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
spaces around -
Thanks @gaffney2010 :) |
Short and simple one.
/~https://github.com/Axelrod-Python/TourExec/blob/v0.2.0/src/strategies/k35r.f
FPs: