Skip to content
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

Adding contrite TfT #639

Merged
merged 8 commits into from
Jun 21, 2016
Merged

Adding contrite TfT #639

merged 8 commits into from
Jun 21, 2016

Conversation

drvinceknight
Copy link
Member

Closes #636

A strategy that plays like TfT if there is no noise. If there is noise and it defects because of noise (intending to cooperate), if the opponent cooperates but defects as a result of the noisy defection then it cooperates to try and bring back mutual cooperation.

Wasn't sure if there was a better way to handling the renaming from the TrackHistoryTransformer (without my change it adds a prefix to the strategy)?

Note that this is on top of #638 (as it needed that fix to work for the 'reduce to tft' test to work).

The test checks that the reset method changes the value of the state.
Is there a better way of doing this?
Tests fail here as I have a test that identifies a bug:
#637

Working on a fix :)

TODO: Still need actual tests of the strategy
if not opponent.history:
return C

# If contrite and but managed to cooperate: apologise.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just a typo in the comment - 'and but'

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixing now :)

@marcharper
Copy link
Member

Wasn't sure if there was a better way to handling the renaming from the TrackHistoryTransformer (without my change it adds a prefix to the strategy)?

You could just make a new instance:

transformer = StrategyTransformerFactory(
    history_track_wrapper, name_prefix="")()

The prefix is there to prevent overwriting the original class; in this case it doesn't matter but it may in other contexts. I'd prefer to leave the default with some prefix. Actually, the transformer is supposed to take a name_prefix parameter:

        def __call__(self, PlayerClass):
            """
            Parameters
            ----------
            PlayerClass: A subclass of axelrod.Player, e.g. Cooperator
                The Player Class to modify
            name_prefix: str
                A string to prepend to the Player and Class name

so that the following would work:

@TrackHistoryTransformer(name_prefix='')
class MyPlayer(object):
    name = "MyName"
print(MyPlayer().name)

but as you can see it's not implemented properly.

@drvinceknight
Copy link
Member Author

Thanks: have fixed that using your suggestion.

The prefix is there to prevent overwriting the original class; in this case it doesn't matter but it may in other contexts. I'd prefer to leave the default with some prefix.

Me too, I like having the prefix. Would be great to be able to pass the prefix (or None) to the decorator as you said there. I'll open an issue for it (also, note that FinalTransformer does not have a prefix (used by Backstabber). That should be addressed too.

@drvinceknight
Copy link
Member Author

Have opened #642

@marcharper marcharper merged commit 579f188 into master Jun 21, 2016
@marcharper marcharper deleted the 636 branch July 22, 2016 16:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Adding Contrite TfT
3 participants