-
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
3 New Strategies From the PRISON (http://www.lifl.fr/IPD/ipd.frame.html) #715
3 New Strategies From the PRISON (http://www.lifl.fr/IPD/ipd.frame.html) #715
Conversation
Hi! Just looked at Issue #379 and implemented 3 new strategies. Hope this helps 😄 |
""" | ||
It begins by defecting in the first five moves, then cooperates two times. | ||
It then defects all the time if the opponent has defected in move 6 and 7, | ||
else cooperates all the time. |
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 you add a sentence here saying that this is designed to stop Gradual
from winning? (And possibly why?)
if len(self.history) < 7: | ||
return firstseven[len(self.history)] | ||
# React to the opponent's 6th and 7th moves | ||
elif opponent.history[5:7] == [D, D]: |
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 can just be an if
statement.
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've spoken, it must be elif
|
||
class GrudgerAlternator(Player): | ||
""" | ||
A player starts by cooperating until the first opponents defenction, |
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.
"defection"
|
||
Names: | ||
|
||
- c_then_per_dc: [PRISON1998]_ |
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.
Can you also add GrudgerAlternator
to this list?
|
||
class EasyGo(Player): | ||
""" | ||
A player starts by defecting however will cooperate if at any point the opponent has defected. |
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.
if the opponent
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.
Ignore this.
@@ -18,3 +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). |
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.
Is there no academic reference?
expected_response = [D if r % 2 == 0 else C for r in range(j)] | ||
self.responses_test(my_hist, opp_hist, expected_response) | ||
|
||
|
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.
Can you get rid of the extra lines? Should be 2.
def strategy(self, opponent): | ||
"""This is the actual strategy""" | ||
# First seven moves | ||
firstseven = [D, D, D, D, D, C, 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 have the @initial_sequence
decorator to handle this
# return D | ||
# return C | ||
|
||
if len(self.history) >= 7: |
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 this condition is redundant now that the decorator is being used
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.
Wouldn't this line:
if opponent.history[5:7] == [D, D]:
not break before the 7th round?
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.
The decorator should override it in the early turns. Try 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.
You're right! 👍
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 try to be once a month or so!
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.
Looks good pending the tests all passing, thanks!
} | ||
|
||
def strategy(self, opponent): | ||
"""This is the actual strategy""" |
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.
Please delete this line and the commented lines below.
Names: | ||
|
||
- c_then_per_dc: [PRISON1998]_ | ||
- GrudgerAlternator |
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.
Can you make this something like:
- Grudger Alternator: Original name by Geraint Palmer
Or whatever self attribution you would like to use?
EasyGo
GrudgerAlternator
GradualKiller