Skip to content

Commit 609d27b

Browse files
committed
Add sources for some strategies.
Ongoing work on #225
1 parent fc8f01c commit 609d27b

File tree

11 files changed

+133
-31
lines changed

11 files changed

+133
-31
lines changed

axelrod/strategies/alternator.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,13 @@
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: [Bendor1993]_
14+
"""
915

1016
name = 'Alternator'
1117
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 2007: [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/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: Original name by Marc Harper
1318
"""
1419

1520
name = "Calculator"

axelrod/strategies/cooperator.py

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,12 @@
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+
"""
914

1015
name = 'Cooperator'
1116
classifier = {
@@ -24,7 +29,13 @@ def strategy(opponent: Player) -> Action:
2429

2530

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

2940
name = "Tricky Cooperator"
3041
classifier = {

axelrod/strategies/cycler.py

Lines changed: 48 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,13 @@ 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+
"""
108130
name = 'Cycler CCD'
109131
classifier = copy.copy(Cycler.classifier)
110132
classifier['memory_depth'] = 2
@@ -114,7 +136,13 @@ def __init__(self) -> None:
114136

115137

116138
class CyclerDDC(Cycler):
139+
"""
140+
Cycles D, D, C
117141
142+
Names:
143+
144+
- Cycler DDC: Original name by Marc Harper
145+
"""
118146
name = 'Cycler DDC'
119147
classifier = copy.copy(Cycler.classifier)
120148
classifier['memory_depth'] = 2
@@ -124,7 +152,13 @@ def __init__(self) -> None:
124152

125153

126154
class CyclerCCCD(Cycler):
155+
"""
156+
Cycles C, C, C, D
127157
158+
Names:
159+
160+
- Cycler CCCD: Original name by Marc Harper
161+
"""
128162
name = 'Cycler CCCD'
129163
classifier = copy.copy(Cycler.classifier)
130164
classifier['memory_depth'] = 3
@@ -134,7 +168,13 @@ def __init__(self) -> None:
134168

135169

136170
class CyclerCCCCCD(Cycler):
171+
"""
172+
Cycles C, C, C, C, C, D
137173
174+
Names:
175+
176+
- Cycler CCCD: Original name by Marc Harper
177+
"""
138178
name = 'Cycler CCCCCD'
139179
classifier = copy.copy(Cycler.classifier)
140180
classifier['memory_depth'] = 5
@@ -144,6 +184,13 @@ def __init__(self) -> None:
144184

145185

146186
class CyclerCCCDCD(Cycler):
187+
"""
188+
Cycles C, C, C, D, C, D
189+
190+
Names:
191+
192+
- Cycler CCCDCD: Original name by Marc Harper
193+
"""
147194

148195
name = 'Cycler CCCDCD'
149196
classifier = copy.copy(Cycler.classifier)

axelrod/strategies/darwin.py

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -10,20 +10,25 @@
1010

1111

1212
class Darwin(Player):
13-
""" A strategy which accumulates a record (the 'genome') of what the most
14-
favourable response in the previous round should have been, and naively
15-
assumes that this will remain the correct response at the same round of
16-
future trials.
13+
"""
14+
A strategy which accumulates a record (the 'genome') of what the most
15+
favourable response in the previous round should have been, and naively
16+
assumes that this will remain the correct response at the same round of
17+
future trials.
18+
19+
This 'genome' is preserved between opponents, rounds and repetitions of
20+
the tournament. It becomes a characteristic of the type and so a single
21+
version of this is shared by all instances for each loading of the class.
22+
23+
As this results in information being preserved between tournaments, this
24+
is classified as a cheating strategy!
1725
18-
This 'genome' is preserved between opponents, rounds and repetitions of
19-
the tournament. It becomes a characteristic of the type and so a single
20-
version of this is shared by all instances for each loading of the class.
26+
If no record yet exists, the opponent's response from the previous round
27+
is returned.
2128
22-
As this results in information being preserved between tournaments, this
23-
is classified as a cheating strategy!
29+
Names:
2430
25-
If no record yet exists, the opponent's response from the previous round
26-
is returned.
31+
- Darwin: Original name by Paul Slavin
2732
"""
2833

2934
name = "Darwin"

docs/reference/bibliography.rst

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,16 +17,17 @@ documentation.
1717
.. [Au2006] Au, T.-C. and Nau, D. S. (2006) Accident or intention: That is the question (in the iterated prisoner’s dilemma). In Proc. Int. Conf. Auton. Agents and Multiagent Syst. (AAMAS), pp. 561–568. http://www.cs.umd.edu/~nau/papers/au2006accident.pdf
1818
.. [Axelrod1980] Axelrod, R. (1980). Effective Choice in the Prisoner’s Dilemma. Journal of Conflict Resolution, 24(1), 3–25.
1919
.. [Axelrod1980b] Axelrod, R. (1980). More Effective Choice in the Prisoner’s Dilemma. Journal of Conflict Resolution, 24(3), 379-403.
20-
.. [Axelrod1984] The Evolution of Cooperation. Basic Books. ISBN 0-465-02121-2.
20+
.. [Axelrod1984] The Evolution of Cooperation. Basic Books. ISBN 0-465-02121-2.
2121
.. [Axelrod1995] Wu, J. and Axelrod, R. (1995). How to cope with noise in the Iterated prisoner’s dilemma, Journal of Conflict Resolution, 39(1), pp. 183–189. doi: 10.1177/0022002795039001008.
2222
.. [Banks1980] Banks, J. S., & Sundaram, R. K. (1990). Repeated games, finite automata, and complexity. Games and Economic Behavior, 2(2), 97–117. http://doi.org/10.1016/0899-8256(90)90024-O
23-
.. [Bendor1993] Bendor, Jonathan, et al. “Cooperation Under Uncertainty: What Is New, What Is True, and What Is Important.” American Sociological Review, vol. 61, no. 2, 1996, pp. 333–338., www.jstor.org/stable/2096337.
23+
.. [Bendor1993] Bendor, Jonathan. "Uncertainty and the Evolution of Cooperation." The Journal of Conflict Resolution, 37(4), 709–734.
2424
.. [Beaufils1997] Beaufils, B. and Delahaye, J. (1997). Our Meeting With Gradual: A Good Strategy For The Iterated Prisoner’s Dilemma. http://citeseerx.ist.psu.edu/viewdoc/summary?doi=10.1.1.42.4041
2525
.. [Berg2015] Berg, P. Van Den, & Weissing, F. J. (2015). The importance of mechanisms for the evolution of cooperation. Proceedings of the Royal Society B-Biological Sciences, 282.
2626
.. [Frean1994] Frean, Marcus R. “The Prisoner's Dilemma without Synchrony.” Proceedings: Biological Sciences, vol. 257, no. 1348, 1994, pp. 75–79. www.jstor.org/stable/50253.
2727
.. [Hilde2013] Hilbe, C., Nowak, M.A. and Traulsen, A. (2013). Adaptive dynamics of extortion and compliance, PLoS ONE, 8(11), p. e77886. doi: 10.1371/journal.pone.0077886.
2828
.. [Kraines1989] Kraines, D. & Kraines, V. Theor Decis (1989) 26: 47. doi:10.1007/BF00134056
2929
.. [LessWrong2011] Zoo of Strategies (2011) LessWrong. Available at: http://lesswrong.com/lw/7f2/prisoners_dilemma_tournament_results/
30+
.. [Li2007] Li, J, How to Design a Strategy to Win an IPD Tournament, in Kendall G., Yao X. and Chong S. (eds.) The iterated prisoner’s dilemma: 20 years on. World Scientific, chapter 4, pp. 29-40, 2007.
3031
.. [Li2009] Li, J. & Kendall, G. (2009). A Strategy with Novel Evolutionary Features for the Iterated Prisoner’s Dilemma. Evolutionary Computation 17(2): 257–274.
3132
.. [Li2011] Li, J., Hingston, P., Member, S., & Kendall, G. (2011). Engineering Design of Strategies for Winning Iterated Prisoner ’ s Dilemma Competitions, 3(4), 348–360.
3233
.. [Li2016] Li, J. and Kendall, G. (2016). The Effect of Memory Size on the Evolutionary Stability of Strategies in Iterated Prisoner's Dilemma. IEEE Transactions on Evolutionary Computation, 18(6) 819-826

0 commit comments

Comments
 (0)