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

Include some references and names for strategies. #741

Merged
merged 20 commits into from
Oct 13, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 11 additions & 4 deletions axelrod/strategies/punisher.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@ class Punisher(Player):
opponent has defected, but forgets after meme_length matches, with
1<=mem_length<=20 proportional to the amount of time the opponent has
played D, punishing that player for playing D too often.

Names:

- Punisher: Original by Geraint Palmer
"""

name = 'Punisher'
Expand Down Expand Up @@ -62,10 +66,13 @@ def reset(self):

class InversePunisher(Player):
"""
A player starts by cooperating however will defect if at any point the
opponent has defected, but forgets after mem_length matches, with
1 <= mem_length <= 20 proportional to the amount of time the opponent
has played C. The inverse of Punisher.
An inverted version of Punisher. Similarly the player starts by cooperating however will defect if at any point the
opponent has defected, but forgets after mem_length matches, with 1 <= mem_length <= 20. This time mem_length is
proportional to the amount of time the opponent has played C.

Names:

- Inverse Punisher: Original by Geraint Palmer
"""

name = 'Inverse Punisher'
Expand Down
30 changes: 25 additions & 5 deletions axelrod/strategies/qlearner.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,15 @@


class RiskyQLearner(Player):
"""A player who learns the best strategies through the q-learning algorithm.
"""A player who learns the best strategies through the q-learning
algorithm.

This Q learner is quick to come to conclusions and doesn't care about the
future.

Names:

This qlearner is quick to come to conclusions and doesn't care about the future.
- Risky Q Learner: Original strategy by Geraint Palmer
"""

name = 'Risky QLearner'
Expand Down Expand Up @@ -109,9 +115,14 @@ def reset(self):


class ArrogantQLearner(RiskyQLearner):
"""A player who learns the best strategies through the q-learning algorithm.
"""A player who learns the best strategies through the q-learning
algorithm.

This Q learner jumps to quick conclusions and cares about the future.

This Q learner jumps to quick conclusions and care about the future.
Names:

- Arrogant Q Learner: Original strategy by Geraint Palmer
"""

name = 'Arrogant QLearner'
Expand All @@ -123,6 +134,10 @@ class HesitantQLearner(RiskyQLearner):
"""A player who learns the best strategies through the q-learning algorithm.

This Q learner is slower to come to conclusions and does not look ahead much.

Names:

- Hesitant Q Learner: Original strategy by Geraint Palmer
"""

name = 'Hesitant QLearner'
Expand All @@ -133,7 +148,12 @@ class HesitantQLearner(RiskyQLearner):
class CautiousQLearner(RiskyQLearner):
"""A player who learns the best strategies through the q-learning algorithm.

This Q learner is slower to come to conclusions and wants to look ahead more.
This Q learner is slower to come to conclusions and wants to look ahead
more.

Names:

- Cautious Q Learner: Original strategy by Geraint Palmer
"""

name = 'Cautious QLearner'
Expand Down
7 changes: 6 additions & 1 deletion axelrod/strategies/rand.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,12 @@


class Random(Player):
"""A player who randomly chooses between cooperating and defecting."""
"""A player who randomly chooses between cooperating and defecting.

Names:

- Random: [Axelrod1980]_
"""

name = 'Random'
classifier = {
Expand Down
24 changes: 24 additions & 0 deletions axelrod/strategies/retaliate.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@ class Retaliate(Player):
"""
A player starts by cooperating but will retaliate once the opponent
has won more than 10 percent times the number of defections the player has.

Names:

- Retaliate: Original strategy by Owen Campbell
"""

name = 'Retaliate'
Expand Down Expand Up @@ -58,6 +62,10 @@ def reset(self):
class Retaliate2(Retaliate):
"""
Retaliate player with a threshold of 8 percent.

Names:

- Retaliate2: Original strategy by Owen Campbell
"""

name = 'Retaliate 2'
Expand All @@ -70,6 +78,10 @@ def __init__(self, retaliation_threshold=0.08):
class Retaliate3(Retaliate):
"""
Retaliate player with a threshold of 5 percent.

Names:

- Retaliate3: Original strategy by Owen Campbell
"""

name = 'Retaliate 3'
Expand All @@ -85,6 +97,10 @@ class LimitedRetaliate(Player):
It will then retaliate by defecting. It stops when either, it has beaten
the opponent 10 times more often that it has lost or it reaches the
retaliation limit (20 defections).

Names:

- LimitedRetaliate: Original strategy by Owen Campbell
"""

name = 'Limited Retaliate'
Expand Down Expand Up @@ -162,6 +178,10 @@ class LimitedRetaliate2(LimitedRetaliate):
"""
LimitedRetaliate player with a threshold of 8 percent and a
retaliation limit of 15.

Names:

- LimitedRetaliate2: Original strategy by Owen Campbell
"""

name = 'Limited Retaliate 2'
Expand All @@ -176,6 +196,10 @@ class LimitedRetaliate3(LimitedRetaliate):
"""
LimitedRetaliate player with a threshold of 5 percent and a
retaliation limit of 20.

Names:

- LimitedRetaliate3: Original strategy by Owen Campbell
Copy link
Member

Choose a reason for hiding this comment

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

Just pinging @meatballs to check that these (see above) where indeed his.

Copy link
Member Author

Choose a reason for hiding this comment

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

We confirmed it in PyCon. But I'll make sure to ping the author for now on.

Copy link
Member

Choose a reason for hiding this comment

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

Guilty

Copy link
Member

Choose a reason for hiding this comment

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

We confirmed it in PyCon. But I'll make sure to ping the author for now on.

No that's cool, hadn't realised you had chatted :) 👍

Copy link
Member Author

Choose a reason for hiding this comment

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

😄

"""

name = 'Limited Retaliate 3'
Expand Down
19 changes: 14 additions & 5 deletions axelrod/strategies/sequence_player.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@

class SequencePlayer(Player):
"""Abstract base class for players that use a generated sequence to
determine their plays."""
determine their plays.
"""

@init_args
def __init__(self, generator_function, generator_args=()):
Expand Down Expand Up @@ -37,9 +38,14 @@ def reset(self):
class ThueMorse(SequencePlayer):
"""
A player who cooperates or defects according to the Thue-Morse sequence.

The first few terms of the Thue-Morse sequence are:
0 1 1 0 1 0 0 1 1 0 0 1 0 1 1 0 . . .

Thue-Morse sequence: http://mathworld.wolfram.com/Thue-MorseSequence.html

Names:

- Thue Morse: Original by Geraint Palmer
"""

name = 'ThueMorse'
Expand All @@ -59,8 +65,12 @@ def __init__(self):


class ThueMorseInverse(ThueMorse):
"""A player who defects or cooperates according to the Thue-Morse sequence
(Inverse of ThueMorse)."""
""" A player who plays the inverse of the Thue-Morse sequence.

Names:

- Inverse Thue Morse: Original by Geraint Palmer
"""

name = 'ThueMorseInverse'
classifier = {
Expand All @@ -83,4 +93,3 @@ def meta_strategy(self, value):
return Actions.C
else:
return Actions.D

Loading