-
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
Implemented WmAdams strategy (k44r from Axelrod's second) #1142
Merged
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
a643480
Implemented WmAdams strategy (k44r from Axelrod's second)
gaffney2010 c20a106
Merge http://github.com/Axelrod-Python/Axelrod
gaffney2010 90c529b
Fixed formatting issues mentioned in PR
gaffney2010 da80753
Minor formatting fixes.
gaffney2010 dd91f0a
Subtracted first defect.
gaffney2010 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
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
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.
@gaffney2010 can you confirm which strategy this is? Looking at /~https://github.com/Axelrod-Python/TourExec/blob/master/src/strategies/k44r.f I don't immediately follow how this implementation corresponds to
k44r
?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 can confirm that it's k44r. I'll say more about the translation...
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 confirm I get the same fingerprints :)
I think you've just done a good job refactoring and re writing the code to be much more readable, just got me scratching my head to follow along, so one or two pointers for my own benefit just to confirm would be awesome (even if it's not in the PR itself but just in a comment here).
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 ones I'm particularly stumped by are the comparisons of
number_defects
to 4, 7 and 9 and also wherenumber_defects - 9
comes from...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.
Basically every time a defect comes up, it increments this MC variable. While AM is still a whole number, then MC is either less than AM or equal to AM. [While less than, line 16 returns C.] While MC=AM it defects; this happens for the first time at 4 defects [line 11]. As soon as MC exceeds AM, then AM is halved, and MC is reset to zero. [The 5th defect resets MC and sets AM to 2. So the 7th defect gets MC=AM. Then the 8th defect resets MC and sets AM to 1. So the 9th defect gets MC=AM]
After the 9th defect, the function changes because the AM is no longer whole, so MC never again equal AM (and line 17 is out of play). So as soon as MC is incremented (any defect), lines 19-22 are triggered. [Line 22 was 100% until now.] And MC is immediately reset, so there's no sustained defecting, like there was earlier. [For example, there could be exactly 4 defects for many turns, and the strategy would defect for all those turns. But after the 100th defect, the strategy will defect (with some probability) ONLY once.]
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.
That's awesome and make sense. Thanks for explaining.
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.
number_defects - 9
just makes the AM follow the right halving pattern. AM starts at 4.0 and halves after the 4th and 7th, for AM=1.0. After the 9th defect EACH defect will trigger a halving.