-
Notifications
You must be signed in to change notification settings - Fork 267
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 From the PRISON (http://www.lifl.fr/IPD/ipd.frame.html) #720
Closed
Closed
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
72f254d
Added Worse and worse stratergy & test
AdamPohl b4ddcd4
updating fork
AdamPohl f3a6507
Fixing merge conflicts :smiling_imp:
AdamPohl 957a3d0
Merge branch 'master' of github.com:Huaraz2/Axelrod; branch 'master' …
AdamPohl f790fe5
Hopefully fixing the test issues :smiling_imp:
AdamPohl e5fb6c5
Have made the changes that @meatballs asked for. :smiling_imp:
AdamPohl 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 |
---|---|---|
@@ -0,0 +1,35 @@ | ||
from axelrod import Actions, Player | ||
from random import randint | ||
|
||
class WorseAndWorse (Player): | ||
""" | ||
Defects with probability of 'current turn / total no. of turns'. Therefore | ||
it is more and more likely to defect as the round goes on. | ||
|
||
Names: | ||
- worse_and_worse: [PRISON1998] | ||
|
||
""" | ||
|
||
name = 'Worse and worse' | ||
classifier = { | ||
'memory_depth': float('inf'), | ||
'stochastic': True, | ||
'makes_use_of': set(['length']), | ||
'long_run_time': False, | ||
'inspects_source': False, | ||
'manipulates_source': False, | ||
'manipulates_state': False | ||
} | ||
|
||
def strategy(self, opponent): | ||
current_round = len(self.history) + 1 | ||
expected_length = self.match_attributes['length'] | ||
try: | ||
if randint(0, expected_length) < (current_round): | ||
return Actions.D | ||
return Actions.C | ||
except: | ||
if randint(0, 200) < (current_round): | ||
return Actions.D | ||
return Actions.C |
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 |
---|---|---|
@@ -0,0 +1,33 @@ | ||
"""Test for the Worse and Worse strategy.""" | ||
|
||
import axelrod | ||
|
||
from .test_player import TestPlayer | ||
|
||
C, D = axelrod.Actions.C, axelrod.Actions.D | ||
|
||
|
||
class TestWorseAndWorse(TestPlayer): | ||
|
||
name = "Worse and worse" | ||
player = axelrod.WorseAndWorse | ||
expected_classifier = { | ||
'memory_depth': float('inf'), | ||
'stochastic': True, | ||
'makes_use_of': set(['length']), | ||
'long_run_time': False, | ||
'inspects_source': False, | ||
'manipulates_source': False, | ||
'manipulates_state': False | ||
} | ||
|
||
def test_strategy(self): | ||
""" | ||
Test that the stratergy chooses to defect according to the correct | ||
probability. | ||
""" | ||
self.responses_test([], [], [C, C, D, D, D], random_seed=1, | ||
tournament_length=5) | ||
|
||
self.responses_test([], [], [D, D, D, D, D], random_seed=2, | ||
tournament_length=5) |
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 |
---|---|---|
|
@@ -18,4 +18,4 @@ documentation. | |
.. [Stewart2012] Stewart, a. J., & Plotkin, J. B. (2012). Extortion and cooperation in the Prisoner’s Dilemma. Proceedings of the National Academy of Sciences, 109(26), 10134–10135. http://doi.org/10.1073/pnas.1208087109 | ||
.. [Szabó1992] Szabó, G., & Fáth, G. (2007). Evolutionary games on graphs. Physics Reports, 446(4-6), 97–216. http://doi.org/10.1016/j.physrep.2007.04.004 | ||
.. [Tzafestas2000] Tzafestas, E. (2000). Toward adaptive cooperative behavior. From Animals to Animals: Proceedings of the 6th International Conference on the Simulation of Adaptive Behavior {(SAB-2000)}, 2, 334–340. | ||
.. [PRISON1998] LIFL (1998) PRISON. Available at: http://www.lifl.fr/IPD/ipd.frame.html (Accessed: 19 September 2016). | ||
.. [PRISON1998] LIFL (1998) PRISON. Available at: http://www.lifl.fr/IPD/ipd.frame.html (Accessed: 19 September 2016). | ||
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. Looks like you deleted this line but this is in the master branch so best go with it. |
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
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.
I haven't reviewed the strategy properly (once all tests are sorted I will) but this general except is not great: better to catch the actual error. Also, not sure why you're hardcoding 200, is that just for some tests when the
match_attributes
isn't passed? I think I'd prefer a different default behaviour there, perhaps just cooperate or defect or randomly cooperate or defect...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.
@drvinceknight would you prefer it to be an if/else statement? The reason why travis is failing is because random.seed(1) and random.seed(2) are different for python 2.7 and python 3