Skip to content

Commit dcb0333

Browse files
authored
Merge pull request #741 from Nikoleta-v3/225
Include some references and names for strategies.
2 parents b225348 + 2c0ee46 commit dcb0333

File tree

7 files changed

+177
-56
lines changed

7 files changed

+177
-56
lines changed

axelrod/strategies/punisher.py

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,10 @@ class Punisher(Player):
88
opponent has defected, but forgets after meme_length matches, with
99
1<=mem_length<=20 proportional to the amount of time the opponent has
1010
played D, punishing that player for playing D too often.
11+
12+
Names:
13+
14+
- Punisher: Original by Geraint Palmer
1115
"""
1216

1317
name = 'Punisher'
@@ -62,10 +66,13 @@ def reset(self):
6266

6367
class InversePunisher(Player):
6468
"""
65-
A player starts by cooperating however will defect if at any point the
66-
opponent has defected, but forgets after mem_length matches, with
67-
1 <= mem_length <= 20 proportional to the amount of time the opponent
68-
has played C. The inverse of Punisher.
69+
An inverted version of Punisher. Similarly the player starts by cooperating however will defect if at any point the
70+
opponent has defected, but forgets after mem_length matches, with 1 <= mem_length <= 20. This time mem_length is
71+
proportional to the amount of time the opponent has played C.
72+
73+
Names:
74+
75+
- Inverse Punisher: Original by Geraint Palmer
6976
"""
7077

7178
name = 'Inverse Punisher'

axelrod/strategies/qlearner.py

Lines changed: 25 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,15 @@
77

88

99
class RiskyQLearner(Player):
10-
"""A player who learns the best strategies through the q-learning algorithm.
10+
"""A player who learns the best strategies through the q-learning
11+
algorithm.
12+
13+
This Q learner is quick to come to conclusions and doesn't care about the
14+
future.
15+
16+
Names:
1117
12-
This qlearner is quick to come to conclusions and doesn't care about the future.
18+
- Risky Q Learner: Original strategy by Geraint Palmer
1319
"""
1420

1521
name = 'Risky QLearner'
@@ -109,9 +115,14 @@ def reset(self):
109115

110116

111117
class ArrogantQLearner(RiskyQLearner):
112-
"""A player who learns the best strategies through the q-learning algorithm.
118+
"""A player who learns the best strategies through the q-learning
119+
algorithm.
120+
121+
This Q learner jumps to quick conclusions and cares about the future.
113122
114-
This Q learner jumps to quick conclusions and care about the future.
123+
Names:
124+
125+
- Arrogant Q Learner: Original strategy by Geraint Palmer
115126
"""
116127

117128
name = 'Arrogant QLearner'
@@ -123,6 +134,10 @@ class HesitantQLearner(RiskyQLearner):
123134
"""A player who learns the best strategies through the q-learning algorithm.
124135
125136
This Q learner is slower to come to conclusions and does not look ahead much.
137+
138+
Names:
139+
140+
- Hesitant Q Learner: Original strategy by Geraint Palmer
126141
"""
127142

128143
name = 'Hesitant QLearner'
@@ -133,7 +148,12 @@ class HesitantQLearner(RiskyQLearner):
133148
class CautiousQLearner(RiskyQLearner):
134149
"""A player who learns the best strategies through the q-learning algorithm.
135150
136-
This Q learner is slower to come to conclusions and wants to look ahead more.
151+
This Q learner is slower to come to conclusions and wants to look ahead
152+
more.
153+
154+
Names:
155+
156+
- Cautious Q Learner: Original strategy by Geraint Palmer
137157
"""
138158

139159
name = 'Cautious QLearner'

axelrod/strategies/rand.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,12 @@
22

33

44
class Random(Player):
5-
"""A player who randomly chooses between cooperating and defecting."""
5+
"""A player who randomly chooses between cooperating and defecting.
6+
7+
Names:
8+
9+
- Random: [Axelrod1980]_
10+
"""
611

712
name = 'Random'
813
classifier = {

axelrod/strategies/retaliate.py

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,10 @@ class Retaliate(Player):
99
"""
1010
A player starts by cooperating but will retaliate once the opponent
1111
has won more than 10 percent times the number of defections the player has.
12+
13+
Names:
14+
15+
- Retaliate: Original strategy by Owen Campbell
1216
"""
1317

1418
name = 'Retaliate'
@@ -58,6 +62,10 @@ def reset(self):
5862
class Retaliate2(Retaliate):
5963
"""
6064
Retaliate player with a threshold of 8 percent.
65+
66+
Names:
67+
68+
- Retaliate2: Original strategy by Owen Campbell
6169
"""
6270

6371
name = 'Retaliate 2'
@@ -70,6 +78,10 @@ def __init__(self, retaliation_threshold=0.08):
7078
class Retaliate3(Retaliate):
7179
"""
7280
Retaliate player with a threshold of 5 percent.
81+
82+
Names:
83+
84+
- Retaliate3: Original strategy by Owen Campbell
7385
"""
7486

7587
name = 'Retaliate 3'
@@ -85,6 +97,10 @@ class LimitedRetaliate(Player):
8597
It will then retaliate by defecting. It stops when either, it has beaten
8698
the opponent 10 times more often that it has lost or it reaches the
8799
retaliation limit (20 defections).
100+
101+
Names:
102+
103+
- LimitedRetaliate: Original strategy by Owen Campbell
88104
"""
89105

90106
name = 'Limited Retaliate'
@@ -162,6 +178,10 @@ class LimitedRetaliate2(LimitedRetaliate):
162178
"""
163179
LimitedRetaliate player with a threshold of 8 percent and a
164180
retaliation limit of 15.
181+
182+
Names:
183+
184+
- LimitedRetaliate2: Original strategy by Owen Campbell
165185
"""
166186

167187
name = 'Limited Retaliate 2'
@@ -176,6 +196,10 @@ class LimitedRetaliate3(LimitedRetaliate):
176196
"""
177197
LimitedRetaliate player with a threshold of 5 percent and a
178198
retaliation limit of 20.
199+
200+
Names:
201+
202+
- LimitedRetaliate3: Original strategy by Owen Campbell
179203
"""
180204

181205
name = 'Limited Retaliate 3'

axelrod/strategies/sequence_player.py

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@
44

55
class SequencePlayer(Player):
66
"""Abstract base class for players that use a generated sequence to
7-
determine their plays."""
7+
determine their plays.
8+
"""
89

910
@init_args
1011
def __init__(self, generator_function, generator_args=()):
@@ -37,9 +38,14 @@ def reset(self):
3738
class ThueMorse(SequencePlayer):
3839
"""
3940
A player who cooperates or defects according to the Thue-Morse sequence.
40-
4141
The first few terms of the Thue-Morse sequence are:
4242
0 1 1 0 1 0 0 1 1 0 0 1 0 1 1 0 . . .
43+
44+
Thue-Morse sequence: http://mathworld.wolfram.com/Thue-MorseSequence.html
45+
46+
Names:
47+
48+
- Thue Morse: Original by Geraint Palmer
4349
"""
4450

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

6066

6167
class ThueMorseInverse(ThueMorse):
62-
"""A player who defects or cooperates according to the Thue-Morse sequence
63-
(Inverse of ThueMorse)."""
68+
""" A player who plays the inverse of the Thue-Morse sequence.
69+
70+
Names:
71+
72+
- Inverse Thue Morse: Original by Geraint Palmer
73+
"""
6474

6575
name = 'ThueMorseInverse'
6676
classifier = {
@@ -83,4 +93,3 @@ def meta_strategy(self, value):
8393
return Actions.C
8494
else:
8595
return Actions.D
86-

0 commit comments

Comments
 (0)