-
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
New Strategy From the PRISON (http://www.lifl.fr/IPD/ipd.frame.html) #724
Conversation
I have absolutely no idea as to why the tests are failing, could it be because I am using |
The error messages indicate that you haven't quite coded your strategy right for the case when match lengths are not known by the players. There should not be a need to use I will look through this today and fix it. |
I've opened AdamPohl#1 to your branch @Huaraz2. However, I'm not actually sure this is the correct strategy. I couldn't find this strategy at http://www.lifl.fr/IPD/ipd.frame.html and looking through what I could find in the literature I can't seem to find any details (please point me towards them though). |
Thanks for the pr @drvinceknight, I found this strategy in the classics.str file in the prison package that you can get from the downloads page in the link I have attached to this pr. As far as I understood it, each mactch in the tournament would last for 1000 turns, so I read the strategy as: it defects with probability of current_turn / expected_length. I now do not think this is the case and therefore will rename this one to |
62f4662
to
0209f71
Compare
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 for clarifying the source. I've got a couple of change requests but this is looking like it's on the right road. 👍
class WorseAndWorse (Player): | ||
""" | ||
Defects with probability of 'current turn / 1000'. Therefore | ||
it is more and more likely to defect as the round goes on. |
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:
Source code available at the download tab of [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.
Would this line go at the end of line 10 or do you want it as part of the names section?
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 between line 10 and the names section. So:
Defects with probability ...
is more likely ...
Source code available ...
Names...
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 for the clarification, I have now made this change.
|
||
def strategy(self, opponent): | ||
current_round = len(self.history) + 1 | ||
if random.randint(0, 1000) < current_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.
Can you rewrite this so that it's like the other strategy? IE so that is uses random_choice
:
probability = 1 - float(current_round) / 1000
return random_choice(probability)
When you do that you can remove the import random
at the top of this file.
return C | ||
|
||
|
||
class WorseAndWorseRandom (Player): |
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.
Not a fan of this name: it makes it sound like WorseAndWorse
is not random. As this is a version of WorseAndWorse
that has some knowledge I suggest you call it KnowledgeableWorseAndWorse
.
""" | ||
This strategy is based of 'Worse And Worse' but will defect with probability | ||
of 'current turn / total no. of turns'. | ||
|
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 still needs a names section:
Names:
- Knowledgeable Worse and Worse: Original name by Adam Phol
opponent = axelrod.Cooperator() | ||
player = axelrod.WorseAndWorse() | ||
match = axelrod.Match((opponent, player), turns=5) | ||
self.assertEqual(match.play(), [('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.
Once you've made the expected change, this might change but either way it would be good if you picked a seed that didn't just have WorseAndWorse
cooperate (ie choose one that gives a mix of C and D). Change the strategy first though.
@@ -120,6 +123,6 @@ Here are the docstrings of all the strategies in the library. | |||
.. automodule:: axelrod.strategies.titfortat | |||
:members: | |||
:undoc-members: | |||
.. automodule:: axelrod.strategies.gradualkiller |
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.
Do not delete gradualkiller
.
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 didn't, if you look further up you will see that I moved it so that the list was in alphabetical order again.
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.
Ah great: my mistake :) 👍
@@ -10,11 +8,12 @@ class WorseAndWorse (Player): | |||
it is more and more likely to defect as the round goes on. | |||
|
|||
Names: | |||
- worse_and_worse: [PRISON1998] | |||
- worse_and_worse: Source code available at the download tab of | |||
[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.
Does this indent render ok? (you can run make html
to check from the docs
directory, you might have to pip install a sphinx theme...)
I think the rst syntax should be:
- worse_and_worse: Source code available at the download tab of
[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.
Nearly there as far as I am concerned.
|
||
class KnowledgeableWorseAndWorse (Player): | ||
""" | ||
This strategy is based of 'Worse And Worse' but will defect with probability |
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.
Typo: should be 'is based on'
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, I have now made these changes
|
||
|
||
Names: | ||
- worse_and_worse: [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.
You need the _
at the end of the [PRISON1998]
. So this should be [PRISON1998]_
same for the one above (line 10).
Also can you change it to be:
- Worse and Worse: [PRISON1998]_
@@ -195,12 +195,14 @@ | |||
Willing, | |||
WinShiftLoseStay, | |||
WinStayLoseShift, | |||
WorseAndWorse, | |||
KnowledgeableWorseAndWorse, |
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 put this in alphabetical order please.
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.
Done
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 now looks good to me. We have a two core reviewer policy so it needs to be checked through by someone else. Thanks for your work on it :)
Thanks Vince, it's been fun 👍 |
Implemented
Worse and Worse
strategy as suggested in #379 andKnowledgeable Worse and Worse
which I started during the PyconUK Axelrod sprint. This pr is the same as #720 but now hopefully the appveyer test should pass