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

Implemented White strategy, k72r from Axelrod's Second #1154

Merged
merged 4 commits into from
Dec 21, 2017

Conversation

gaffney2010
Copy link
Member

Fingerprints below.

Notes on refactor from https://github.com/Axelrod-Python/TourExec/blob/v0.3.0/src/strategies/k72r.f :
N, M, and JCOUNT are all integers, so everything gets rounded. So the probability statement (line 12) actually only ever gets run with 0% or 100% (evidenced by the basic-strategy fingerprints). And actually unless the if-statement in line 11 gets run, then the probability statement always Cooperates, since JCOUNT can be at most M-1.

random_fortran
basic_python
basic_fortran
random_python

Copy link
Member

@drvinceknight drvinceknight left a comment

Choose a reason for hiding this comment

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

More of a question then a request but just want to be sure (could indicate an incorrect ranking in axelrod_fortran or an off by 1 error).

Note that changing https://github.com/Axelrod-Python/axelrod-fortran/blob/master/src/axelrod_fortran/strategies.py#L216 to be False so that a value of R of 0 is passed to the Fortran code changes the behaviour of the fortran function.

class White(Player):
"""
Strategy submitted to Axelrod's second tournament by Edward C Whtie (K72R)
and came in twelfth in that tournament.
Copy link
Member

Choose a reason for hiding this comment

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

Copy link
Member Author

Choose a reason for hiding this comment

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

It should say thirteenth, and actually the last few would be off. I'll fix them.

Copy link
Member Author

Choose a reason for hiding this comment

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

I got thrown off at Kluepfel, which had already been implemented since I've started doing these in order.

Copy link
Member Author

Choose a reason for hiding this comment

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

changes the behaviour of the fortran function

Changes how? https://github.com/Axelrod-Python/TourExec/blob/v0.3.0/src/strategies/k72r.f#L12 must be rounding down the right-hand side, otherwise the 100% cooperation in the first ten moves (in the fingerprints) wouldn't make sense.

Copy link
Member

Choose a reason for hiding this comment

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

If you pass a 0 (which is what we do when marking a function as stochastic: False) then the function seems to always defect.

It's not an issue, just noting it. I think that essentially that stochastic: key is whether or not the original Fortran code used the random number anywhere, even if as you've noticed here, it ended up not being relevant.

@drvinceknight
Copy link
Member

Thanks! (my bad for missing those rankings in the docstrings previously. 👍)

@drvinceknight
Copy link
Member

Nudge @marcharper and @meatballs (in case you've missed this): I have checked the logic and this looks good to go 👍


class White(Player):
"""
Strategy submitted to Axelrod's second tournament by Edward C Whtie (K72R)
Copy link
Member

@marcharper marcharper Dec 21, 2017

Choose a reason for hiding this comment

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

Whtie -> White

Strategy submitted to Axelrod's second tournament by Edward C Whtie (K72R)
and came in thirteenth in that tournament.

If the opponent Cooperated last turn or in the first ten turns, then
Copy link
Member

@marcharper marcharper Dec 21, 2017

Choose a reason for hiding this comment

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

"""
*  If the opponent cooperated last turn or in the first ten turns, then
   cooperate.
*  Otherwise defect if and only if:
      floor(log(turn)) * opponent.defections >= turn
"""

@marcharper
Copy link
Member

Looks fine to me, please fix the typo in the name at least.

@gaffney2010
Copy link
Member Author

Made those changes.

@drvinceknight
Copy link
Member

Great. Thanks 👍

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.

None yet

3 participants