-
Notifications
You must be signed in to change notification settings - Fork 269
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
[MRG] Add Resurrection Strategy #865
Conversation
axelrod/strategies/resurrection.py
Outdated
C, D = Actions.C, Actions.D | ||
|
||
|
||
class TitForTat(Player): |
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.
You have named this incorrectly.
The class will also need tests.
Travis seems to error due to this line- https://github.com/Axelrod-Python/Axelrod/pull/865/files#diff-ac262d93edeeeaa83660b643a34b6580R35. Is there a fix for this? |
Yes the error is occurring because your strategy logic is not quite correct:
That first line I believe you want:
|
Thanks a lot @drvinceknight |
The tests for the strategy pass. |
@marcharper I need some help in finishing the PR. |
The tests are currently failing because of the doctests, you need to update the relevant docs:.
|
Done! Fixed the Errors! |
axelrod/strategies/resurrection.py
Outdated
|
||
class Resurrection(Player): | ||
""" | ||
A player starts by cooperating and defects if the the number of rounds |
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.
minor: "the the"
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.
Can you mention that the strategy plays like TFT otherwise?
#Check if turns played are less than 5. | ||
self.responses_test([C], [D, C, D, C], [C] * 4) | ||
|
||
|
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.
Can we add two tests for TFT behaviors after five rounds, and one for more than five rounds, with four defections and a cooperation by the 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.
@marcharper Just to confirm- For first test, the player_history=[C,C,C,C,C,C]
and opponent_history=[C,C,C,C,C,D]
And for second test- the player_history=[C,C,C,C,C]
and opponent_history=[C,D,D,D,D]
, correct?
@souravsingh Just a request for a few more tests, otherwise it's looking good to me. |
axelrod/strategies/resurrection.py
Outdated
played by the player is greater than five and last five rounds are defections. | ||
Otherwise, the strtategy plays like Tit-for-tat. |
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.
"strategy"
Damn! This happened thrice!!
Is the patch ready for merging? |
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.
Sorry for taking a little while to get back to this, just two very minor things from me.
axelrod/strategies/resurrection.py
Outdated
def strategy(self, opponent: Player) -> Action: | ||
if len(self.history) == 0: | ||
return C | ||
if len(self.history) >= 5 and self.history[-5:] == [D,D,D,D,D]: |
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.
Very minor: could you tidy the PEP8 here: [D, D, D, D, D]
.
axelrod/strategies/resurrection.py
Outdated
class Resurrection(Player): | ||
""" | ||
A player starts by cooperating and defects if the number of rounds | ||
played by the player is greater than five and last five rounds are defections. |
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.
and the last five rounds
Also, can you add this module to the index of strategies (so that it's automatically indexed). See http://axelrod.readthedocs.io/en/latest/tutorials/contributing/strategy/adding_the_new_strategy.html:
|
No description provided.