Skip to content

Commit 99d0e2e

Browse files
authored
Merge pull request #1041 from Axelrod-Python/225
Add sources for some strategies.
2 parents fc8f01c + a2a98f4 commit 99d0e2e

40 files changed

+641
-147
lines changed

axelrod/strategies/alternator.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,14 @@
55

66

77
class Alternator(Player):
8-
"""A player who alternates between cooperating and defecting."""
8+
"""
9+
A player who alternates between cooperating and defecting.
10+
11+
Names
12+
13+
- Alternator: [Axelrod1984]_
14+
- Periodic player CD: [Mittal2009]_
15+
"""
916

1017
name = 'Alternator'
1118
classifier = {

axelrod/strategies/ann.py

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,3 @@
1-
"""Artificial Neural Network based strategy.
2-
3-
# Original Source: https://gist.github.com/mojones/550b32c46a8169bb3cd89d917b73111a#file-ann-strategy-test-L60
4-
# Original Author: Martin Jones, @mojones
5-
"""
6-
71
import numpy as np
82

93
from axelrod.actions import Actions, Action
@@ -146,7 +140,9 @@ def split_weights(weights: List[float], num_features: int, num_hidden: int) -> T
146140

147141

148142
class ANN(Player):
149-
"""A single layer neural network based strategy, with the following
143+
"""Artificial Neural Network based strategy.
144+
145+
A single layer neural network based strategy, with the following
150146
features:
151147
* Opponent's first move is C
152148
* Opponent's first move is D
@@ -165,6 +161,13 @@ class ANN(Player):
165161
* Total player cooperations
166162
* Total player defections
167163
* Round number
164+
165+
Original Source: https://gist.github.com/mojones/550b32c46a8169bb3cd89d917b73111a#file-ann-strategy-test-L60
166+
167+
168+
Names
169+
170+
- Artificial Neural Network based strategy: Original name by Martin Jones
168171
"""
169172
name = 'ANN'
170173
classifier = {

axelrod/strategies/apavlov.py

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,14 @@
66

77
class APavlov2006(Player):
88
"""
9-
APavlov as defined in http://www.cs.nott.ac.uk/~pszjl/index_files/chapter4.pdf
10-
(pages 10-11).
11-
129
APavlov attempts to classify its opponent as one of five strategies:
1310
Cooperative, ALLD, STFT, PavlovD, or Random. APavlov then responds in a
1411
manner intended to achieve mutual cooperation or to defect against
1512
uncooperative opponents.
13+
14+
Names:
15+
16+
- Adaptive Pavlov 2006: [Li2007]_
1617
"""
1718

1819
name = "Adaptive Pavlov 2006"
@@ -73,13 +74,14 @@ def reset(self):
7374

7475
class APavlov2011(Player):
7576
"""
76-
APavlov as defined in http://www.graham-kendall.com/papers/lhk2011.pdf, as
77-
closely as can be determined.
78-
7977
APavlov attempts to classify its opponent as one of four strategies:
8078
Cooperative, ALLD, STFT, or Random. APavlov then responds in a manner
8179
intended to achieve mutual cooperation or to defect against
8280
uncooperative opponents.
81+
82+
Names:
83+
84+
- Adaptive Pavlov 2011: [Li2011]_
8385
"""
8486

8587
name = "Adaptive Pavlov 2011"

axelrod/strategies/appeaser.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,10 @@ class Appeaser(Player):
99
1010
Switch the classifier every time the opponent plays 'D'.
1111
Start with 'C', switch between 'C' and 'D' when opponent plays 'D'.
12+
13+
Names:
14+
15+
- Appeaser: Original Name by Jochen Müller
1216
"""
1317

1418
name = 'Appeaser'

axelrod/strategies/averagecopier.py

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,10 @@ class AverageCopier(Player):
99
"""
1010
The player will cooperate with probability p if the opponent's cooperation
1111
ratio is p. Starts with random decision.
12+
13+
Names:
14+
15+
- Average Copier: Original name by Geraint Palmer
1216
"""
1317

1418
name = 'Average Copier'
@@ -31,7 +35,13 @@ def strategy(self, opponent: Player) -> Action:
3135

3236

3337
class NiceAverageCopier(Player):
34-
"""Same as Average Copier, but always starts by cooperating."""
38+
"""
39+
Same as Average Copier, but always starts by cooperating.
40+
41+
Names:
42+
43+
- Average Copier: Original name by Owen Campbell
44+
"""
3545

3646
name = 'Nice Average Copier'
3747
classifier = {

axelrod/strategies/axelrod_first.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -244,8 +244,8 @@ class Joss(MemoryOnePlayer):
244244
245245
Names:
246246
247-
- Joss [Axelrod1980]_
248-
- Hard Joss [Stewart2012]_
247+
- Joss: [Axelrod1980]_
248+
- Hard Joss: [Stewart2012]_
249249
"""
250250

251251
name = "Joss"
@@ -504,7 +504,7 @@ class SteinAndRapoport(Player):
504504
505505
Names:
506506
507-
- SteinAndRapoport [Axelrod1980]_
507+
- SteinAndRapoport: [Axelrod1980]_
508508
"""
509509

510510
name = 'Stein and Rapoport'

axelrod/strategies/backstabber.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,10 @@ class BackStabber(Player):
1010
"""
1111
Forgives the first 3 defections but on the fourth
1212
will defect forever. Defects on the last 2 rounds unconditionally.
13+
14+
Names:
15+
16+
- Backstabber: Original name by Thomas Campbell
1317
"""
1418

1519
name = 'BackStabber'
@@ -36,6 +40,10 @@ class DoubleCrosser(Player):
3640
If 8 <= current round <= 180,
3741
if the opponent did not defect in the first 7 rounds,
3842
the player will only defect after the opponent has defected twice in-a-row.
43+
44+
Names:
45+
46+
- Double Crosser: Original name by Thomas Campbell
3947
"""
4048

4149
name = 'DoubleCrosser'

axelrod/strategies/calculator.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,11 @@ class Calculator(Player):
1010
"""
1111
Plays like (Hard) Joss for the first 20 rounds. If periodic behavior is
1212
detected, defect forever. Otherwise play TFT.
13+
14+
15+
Names:
16+
17+
- Calculator: [Prison1998]_
1318
"""
1419

1520
name = "Calculator"

axelrod/strategies/cooperator.py

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,14 @@
55

66

77
class Cooperator(Player):
8-
"""A player who only ever cooperates."""
8+
"""A player who only ever cooperates.
9+
10+
Names:
11+
12+
- Cooperator: [Axelrod1984]_
13+
- ALLC: [Press2012]_
14+
- Always cooperate: [Mittal2009]_
15+
"""
916

1017
name = 'Cooperator'
1118
classifier = {
@@ -24,7 +31,13 @@ def strategy(opponent: Player) -> Action:
2431

2532

2633
class TrickyCooperator(Player):
27-
"""A cooperator that is trying to be tricky."""
34+
"""
35+
A cooperator that is trying to be tricky.
36+
37+
Names:
38+
39+
- Tricky Cooperator: Original name by Karol Langner
40+
"""
2841

2942
name = "Tricky Cooperator"
3043
classifier = {

axelrod/strategies/cycler.py

Lines changed: 50 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,10 @@ class AntiCycler(Player):
1111
"""
1212
A player that follows a sequence of plays that contains no cycles:
1313
CDD CD CCD CCCD CCCCD ...
14+
15+
Names:
16+
17+
- Anti Cycler: Original name by Marc Harper
1418
"""
1519

1620
name = 'AntiCycler'
@@ -53,7 +57,13 @@ def reset(self):
5357

5458

5559
class Cycler(Player):
56-
"""A player that repeats a given sequence indefinitely."""
60+
"""
61+
A player that repeats a given sequence indefinitely.
62+
63+
Names:
64+
65+
- Cycler: Original name by Marc Harper
66+
"""
5767

5868
name = 'Cycler'
5969
classifier = {
@@ -94,7 +104,13 @@ def reset(self):
94104

95105

96106
class CyclerDC(Cycler):
107+
"""
108+
Cycles D, C
97109
110+
Names:
111+
112+
- Cycler DC: Original name by Marc Harper
113+
"""
98114
name = 'Cycler DC'
99115
classifier = copy.copy(Cycler.classifier)
100116
classifier['memory_depth'] = 1
@@ -104,7 +120,14 @@ def __init__(self) -> None:
104120

105121

106122
class CyclerCCD(Cycler):
123+
"""
124+
Cycles C, C, D
107125
126+
Names:
127+
128+
- Cycler CCD: Original name by Marc Harper
129+
- Periodic player CCD: [Mittal2009]_
130+
"""
108131
name = 'Cycler CCD'
109132
classifier = copy.copy(Cycler.classifier)
110133
classifier['memory_depth'] = 2
@@ -114,7 +137,14 @@ def __init__(self) -> None:
114137

115138

116139
class CyclerDDC(Cycler):
140+
"""
141+
Cycles D, D, C
117142
143+
Names:
144+
145+
- Cycler DDC: Original name by Marc Harper
146+
- Periodic player DDC: [Mittal2009]_
147+
"""
118148
name = 'Cycler DDC'
119149
classifier = copy.copy(Cycler.classifier)
120150
classifier['memory_depth'] = 2
@@ -124,7 +154,13 @@ def __init__(self) -> None:
124154

125155

126156
class CyclerCCCD(Cycler):
157+
"""
158+
Cycles C, C, C, D
127159
160+
Names:
161+
162+
- Cycler CCCD: Original name by Marc Harper
163+
"""
128164
name = 'Cycler CCCD'
129165
classifier = copy.copy(Cycler.classifier)
130166
classifier['memory_depth'] = 3
@@ -134,7 +170,13 @@ def __init__(self) -> None:
134170

135171

136172
class CyclerCCCCCD(Cycler):
173+
"""
174+
Cycles C, C, C, C, C, D
137175
176+
Names:
177+
178+
- Cycler CCCD: Original name by Marc Harper
179+
"""
138180
name = 'Cycler CCCCCD'
139181
classifier = copy.copy(Cycler.classifier)
140182
classifier['memory_depth'] = 5
@@ -144,6 +186,13 @@ def __init__(self) -> None:
144186

145187

146188
class CyclerCCCDCD(Cycler):
189+
"""
190+
Cycles C, C, C, D, C, D
191+
192+
Names:
193+
194+
- Cycler CCCDCD: Original name by Marc Harper
195+
"""
147196

148197
name = 'Cycler CCCDCD'
149198
classifier = copy.copy(Cycler.classifier)

0 commit comments

Comments
 (0)