-
Notifications
You must be signed in to change notification settings - Fork 263
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
New strategy: Graaskamp #1234
New strategy: Graaskamp #1234
Conversation
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.
Thanks for this :)
As we don't have any information on the "analogy" strategy I think we need to make that pretty clear in the docstring.
I'm not sure the entirety of the implementation is right just yet but I've left a few comments, once they're addressed we might need a few more test cases too.
Also, could you modify the table in https://github.com/Axelrod-Python/Axelrod/blob/master/docs/reference/overview_of_strategies.rst about the first tournament to include your implementation (which appears here: https://axelrod.readthedocs.io/en/stable/reference/overview_of_strategies.html#axelrod-s-first-tournament).
Thank You for reply :) Now I see that I've made many mistakes, will correct them as soon as possible. |
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.
Thanks for making some of the changes, there are some remaining requests. Let me know if anything's unclear :)
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.
We're getting there, the main test failure is due to the fact that sometimes your strategy doesn't return anything (I've pointed out where to fix that).
Thanks again, it's looking good 👍
@@ -138,6 +138,31 @@ def test_strategy(self): | |||
self.versus_test(axelrod.Defector(), expected_actions=actions) | |||
|
|||
|
|||
class TestGraaskamp(TestPlayer): | |||
|
|||
name = "Graaskamp" |
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.
Graaskamp: 0.05
(the parameters get automatically added).
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.
I'm not sure what should I do here. Should I add parameters manually somehow for testing? Thanks :)
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.
Yes, you can change the test name to "Graaskamp: 0.05"
|
||
def test_strategy(self): | ||
# Play against opponents | ||
actions = [(C, C), (C, D), (D, C), (C, D), (D, C)] |
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.
These tests are a good start, once you've made the changes I've requested I think we'll need to change one or two and possibly include a few more to ensure we're checking all the described behaviours :) 👍
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.
I've added some more tests :) I think I've found a bug. After round 57 when playing with Grudger, Graaskamp only cooperates. I'm trying to fix this.
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.
I think I might have found what's wrong there: #1234 (comment)
That's almost everything :) I'm not quite sure how to implement tests for opponents playing randomly because of almost 60 rounds of playing randomly and then taking action. How should it look like? |
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.
Two minor points but I think I found what might be wrong with the behaviour against Grudger.
axelrod/strategies/axelrod_first.py
Outdated
return D | ||
return C | ||
|
||
if len(self.history) >= 57: |
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.
No need for this, you can remove the if
statement and simply unindent the rest of the code.
axelrod/strategies/axelrod_first.py
Outdated
if opponent.history[-1] == D: | ||
return D | ||
return C | ||
|
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.
We need to setup a next_random_defection_turn
for the first one so this should be something like:
if self.next_random_defection_turn is None:
self.next_random_defection_turn = random.randint(5, 15) + len(self.history)
if len(self.history) == self.next_random_defection_turn:
self.next_random_defection_turn = random.randint(5, 15) + len(self.history) # resample the next defection turn
return D
return C
Bug where player only cooperates after round 56 still appears. I think it has to do with this line:
|
@kjurgielajtis I've opened kjurgielajtis#1 which includes a number of little tweaks. I wanted to be sure that any suggestions I made no longer included off by one errors etc so I checked them locally. You can either merge that PR (and the changes will automatically update) or just take a look and include the changes manually. You'll notice there was an off by 1 error in the initial TfT play and that I've also written a number of tests and included a couple of comments to show how they match each case of the description. (I believe that catches them all but I might have missed something that the next reviewer might notice.) |
Closed by #1244 |
Hi, I tried my best to contribute to issue #1109 :)