-
Notifications
You must be signed in to change notification settings - Fork 264
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
Track CC, CD, DC, DD in Player class #752
Track CC, CD, DC, DD in Player class #752
Conversation
Initialize Player class with an empty dictionary of paired moves. Update the dictionary when calling play method.
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 a bunch for this @mturzanska, two things:
- a suggested name change for consistency with the rest of the library;
- a slightly expanded test
@@ -60,6 +64,9 @@ def test_play(self): | |||
self.assertEqual(p1.defections, 0) | |||
self.assertEqual(p2.cooperations, 0) | |||
self.assertEqual(p2.defections, 2) | |||
# Test play counts | |||
self.assertEqual(p1.play_counts, {(C, D): 2}) | |||
self.assertEqual(p2.play_counts, {(D, C): 2}) |
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.
Could we have a couple more tests leading to a 'fuller' dictionary please.
@@ -52,6 +53,12 @@ def update_history(player, move): | |||
player.defections += 1 | |||
|
|||
|
|||
def update_play_counts(player, move, reply): |
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.
In the glossary http://axelrod.readthedocs.io/en/latest/reference/glossary.html#a-play we have defined a play as "a single player choosing an action."
In the results set and the interaction utils we have called these counters "state distributions". Could we call them the same thing here (for consistency).
update_state_distribution
player_state_distribution
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.
Sure.
Maybe, because the class is already called Player, the property could be called just state_distribution. What do you think would be better?
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.
Yup: that's better than my suggestion :) 👍
Since we're counting C and D as well for each player (in attributes cooperations and defections), should we change those to a dictionary as well? (Not necessarily in this PR -- there will be a lot of places that need to change.) |
Good idea but yeah: this could/should be another issue. |
Correct variable names and docstrings.
Thanks for the changes @mturzanska, this looks good to me now. |
Related to #744
Add play_counts property to Player class (a dictionary counting occurrences of CC, CD, DC, DD).
Update the dictionary after each play.
Add tests for the property.
TODO:
Use play_counts property in existing strategies (e.g. Prober4, Retaliate)