-
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
Merged
meatballs
merged 6 commits into
Axelrod-Python:master
from
mturzanska:track_action_pairs
Nov 2, 2016
Merged
Changes from 2 commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
5270206
Keep track of player's move-response pairs
ddc0c71
Add tests for the new property
4e5afb4
Rename play_counts to state_distribution
4ae1ee6
Add get_state_distribution_from_history
4b6931a
Add test for updating state distirbution
1b3b134
Review all commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -52,6 +52,10 @@ def test_play(self): | |
self.assertEqual(p1.defections, 0) | ||
self.assertEqual(p2.cooperations, 0) | ||
self.assertEqual(p2.defections, 1) | ||
# Test play counts | ||
self.assertEqual(p1.play_counts, {(C, D): 1}) | ||
self.assertEqual(p2.play_counts, {(D, C): 1}) | ||
|
||
p1.play(p2) | ||
self.assertEqual(p1.history[-1], C) | ||
self.assertEqual(p2.history[-1], D) | ||
|
@@ -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 commentThe 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. |
||
|
||
def test_noisy_play(self): | ||
random.seed(1) | ||
|
@@ -172,6 +179,7 @@ def test_reset(self): | |
self.assertEqual(p.history, []) | ||
self.assertEqual(self.player().cooperations, 0) | ||
self.assertEqual(self.player().defections, 0) | ||
self.assertEqual(self.player().play_counts, {}) | ||
|
||
def test_clone(self): | ||
# Make sure that self.init_args has the right number of arguments | ||
|
@@ -190,6 +198,7 @@ def test_clone(self): | |
self.assertEqual(len(p2.history), 0) | ||
self.assertEqual(p2.cooperations, 0) | ||
self.assertEqual(p2.defections, 0) | ||
self.assertEqual(p2.play_counts, {}) | ||
self.assertEqual(p2.classifier, p1.classifier) | ||
self.assertEqual(p2.match_attributes, p1.match_attributes) | ||
|
||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 :) 👍