-
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
Implement prober4 strategy from PRISON project #743
Merged
Merged
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
dcccd15
Add Prober4 class
0de0b6e
Add classifier to Prober4
3a95e76
Add the strategy to strategies pool
0e6b7d5
Fix bugs
df394b4
Simplify Prober4
49e22d1
Add basic tests for Prober4
9a1ab8f
Add more tests to Prober4
cbb21bd
Review all commits
8e9126f
Update strategies counter
988b849
Incorporate comments
b3eb0ea
Incorporate comment - simplify if statement
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
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 |
---|---|---|
|
@@ -99,6 +99,79 @@ def test_strategy(self): | |
self.responses_test([D, C, C, D, C], [C, D, C, C], [C]) | ||
|
||
|
||
class TestProber4(TestPlayer): | ||
|
||
name = "Prober 4" | ||
player = axelrod.Prober4 | ||
expected_classifier = { | ||
'stochastic': False, | ||
'memory_depth': float('inf'), | ||
'makes_use_of': set(), | ||
'long_run_time': False, | ||
'inspects_source': False, | ||
'manipulates_source': False, | ||
'manipulates_state': False | ||
} | ||
initial_sequence = [ | ||
C, C, D, C, D, D, D, C, C, D, C, D, C, C, D, C, D, D, C, D | ||
] | ||
|
||
def test_initial_strategy(self): | ||
"""Starts by playing CCDCDDDCCDCDCCDCDDCD.""" | ||
self.responses_test([], [], self.initial_sequence) | ||
|
||
def test_strategy(self): | ||
# After playing the initial sequence defects forever | ||
# if the absolute difference in the number of retaliating | ||
# and provocative defections of the opponent is smaller or equal to 2 | ||
|
||
provocative_histories = [ | ||
[C, C, C, C, C, C, C, C, C, C, C, C, C, C, C, C, C, C, C, C], | ||
[C, D, C, C, C, C, C, C, C, C, C, C, C, C, C, C, C, C, C, C], | ||
[C, D, C, D, C, C, C, C, C, C, C, C, C, C, C, C, C, C, C, C], | ||
[C, C, D, C, C, C, C, C, C, C, C, C, C, C, C, C, C, C, C, C], | ||
[C, C, D, C, D, C, C, C, C, C, C, C, C, C, C, C, C, C, C, C], | ||
[D, D, D, D, D, D, D, D, D, D, D, D, D, D, D, D, D, D, D, D], | ||
] | ||
|
||
history1 = self.initial_sequence | ||
responses = [D] * 10 | ||
attrs = {'turned_defector': True} | ||
for history2 in provocative_histories: | ||
self.responses_test(history1, history2, responses, attrs=attrs) | ||
|
||
# Otherwise cooperates for 5 rounds | ||
unprovocative_histories = [ | ||
[C, C, D, C, D, D, D, C, C, D, C, D, C, C, D, C, D, D, C, D], | ||
[D, D, C, D, C, C, C, D, D, C, D, C, D, D, C, D, C, C, D, C], | ||
[C, C, D, C, D, D, C, C, C, C, C, C, C, C, C, C, C, C, C, C], | ||
[C, C, D, C, D, D, C, C, D, C, C, C, C, C, C, D, D, D, C, C], | ||
[C, C, C, C, D, D, C, C, D, C, C, D, D, C, D, C, D, C, C, C], | ||
] | ||
|
||
responses = [C] * 5 | ||
attrs = {'turned_defector': False} | ||
for history2 in unprovocative_histories: | ||
self.responses_test(history1, history2, responses, attrs=attrs) | ||
|
||
# and plays like TFT afterwards | ||
history1 += responses | ||
history2 += responses | ||
self.responses_test(history1, history2, [C], attrs=attrs) | ||
|
||
history1 += [C] | ||
history2 += [D] | ||
self.responses_test(history1, history2, [D], attrs=attrs) | ||
|
||
history1 += [D] | ||
history2 += [C] | ||
self.responses_test(history1, history2, [C], attrs=attrs) | ||
|
||
history1 += [C] | ||
history2 += [D] | ||
self.responses_test(history1, history2, [D], attrs=attrs) | ||
|
||
|
||
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. Can we test that |
||
class TestHardProber(TestPlayer): | ||
|
||
name = "Hard Prober" | ||
|
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.
This is a meta comment for everyone (@drvinceknight @meatballs): we could consider counting CC, CD, DC, DD in the player class like we do for cooperations and defections, since multiple players make use of it.
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 should open an issue for that.
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.
#744