-
Notifications
You must be signed in to change notification settings - Fork 263
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
Added AdaptiveTitForTat #697
Conversation
Thanks @l-liciniuslucullus !
I think your interpretation of the extended strategy is correct -- for a first pass, you could try setting the window to be 10 by default, and a reasonable threshold like 2 (using the example in the captions of figures 7 and 8). So if you want to give that a try that would be awesome :) FYI: we can't always assume that the player will know the number of rounds (many tournaments vary this parameter and leave it unknown for theoretical reasons), so there needs to be a simple default for the window. I'm happy to help modify the strategy to use the number of rounds if it's known to the player (it's a little unusual but we have a few other strategies that use it). |
So I think you can skip the squashing step -- I forgot that github lets us squash on merge now. Sorry @ranjinidas -- that would have made your last PR much easier! |
@init_args | ||
def __init__(self, rate=0.5): | ||
|
||
super().__init__() |
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 line is Python 3 only. We're currently also supporting Python 2.7, so we need to use Player.__init__(self)
instead.
Build is apparently failing due to incompatibility with numpy-like doc: |
The only other error is an overzealous docstring parsing issue (a warning treated as an error by Travis). Can we relax this somehow, @drvinceknight ? Edit: Yep @l-liciniuslucullus , I'm paging @drvinceknight , he's the docs guru. |
We'll probably also want a test or two that checks that |
@@ -197,4 +197,5 @@ | |||
ZDGen2, |
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.
Unless I'm missing it, you need to add AdaptiveTitForTat
to the all_strategies
list. I believe that might trigger a failure in the EDIT: docstrings doctests but that should just require incrementing a count :)
I can't believe we didn't think of that 🙈 :) 👍 A good tactic to keep in mind :)
For the docs to compile we've removed the numpy docstring style guideline in the strategy docstrings (this is because it's automatically creating the html from the docstrings which end up looking like: http://axelrod.readthedocs.io/en/latest/reference/all_strategies.html#axelrod.strategies.titfortat.TitForTat so normal rst sections don't work). If you could just remove all the
Could you also change how you have the reference at the end. You currently have:
To be in line with the way we're doing the rest of the strategies (currently working on this to update all the others) could you change that to:
and add to https://github.com/Axelrod-Python/Axelrod/blob/master/docs/reference/bibliography.rst :
This would then render like the following (with a link to the bibliography :)): |
If there's anything unclear about the docstrings: |
Thanks @drvinceknight , I didn't realize we were enforcing numpy style docstrings, now it makes sense! |
p1.play(p2) | ||
p1.play(p2) | ||
self.assertEqual(p2.world, 0.75) | ||
|
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 we have an extra test for the reset? Just to check that the value of the rate and world go back to the defaults?
If you call it test_reset
it will overwrite the test here: https://github.com/Axelrod-Python/Axelrod/blob/master/axelrod/tests/unit/test_player.py#L163
So perhaps call it test_world_and_rate_reset
(or something like that) :)
No problemo 👍 😄 This is looking good @l-liciniuslucullus, I've just left two comments above, summarised as:
Thanks a bunch for this contribution :) 👍 |
This looks good to me! 👍 Don't forget to do a merge commit @marcharper :) |
Hello,
I've implemented a basic version of Adaptive Tit For Tat based on this paper: http://users.softlab.ntua.gr/~brensham/Publications/SAB2000.pdf)
and some simple tests.
I'm not quite certain about memory-depth of the strategy though - on one hand it's looks at opponents last move (depth=1) on the other it has a continuous variable 'world' that in a peculiar way 'remembers' the whole game (depth=inf).
The paper also mentions a slightly extended model that I could try to implement as well, however, I'm not sure how to implement some of its features(like window or threshold) so that the class is user-friendly and universal ('window' parameter probably should depend on the number of round in a match and threshold somehow on the size of a window and so on). Also authors do not specify whether they mean 'n' move coincidences in a row within the window or simply within the window (I'd assume the latter).
Looking forward to your feedback,
L.