Skip to content

Commit 124359a

Browse files
committed
Add all but 2 remaining strategies.
Currently missing: - Soft Joss. Soft Joss is GTFT with a different parameter. We need to find the literature with that particular parameter. - Also cannot find EXTORT-4
1 parent 05dfbb4 commit 124359a

27 files changed

+460
-90
lines changed

axelrod/strategies/alternator.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ class Alternator(Player):
1111
Names
1212
1313
- Alternator: [Axelrod1984]_
14+
- Periodic player CD: [Mittal2009]_
1415
"""
1516

1617
name = 'Alternator'

axelrod/strategies/cooperator.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ class Cooperator(Player):
1111
1212
- Cooperator: [Axelrod1984]_
1313
- ALLC: [Press2012]_
14+
- Always cooperate: [Mittal2009]_
1415
"""
1516

1617
name = 'Cooperator'

axelrod/strategies/cycler.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,7 @@ class CyclerCCD(Cycler):
126126
Names:
127127
128128
- Cycler CCD: Original name by Marc Harper
129+
- Periodic player CCD: [Mittal2009]_
129130
"""
130131
name = 'Cycler CCD'
131132
classifier = copy.copy(Cycler.classifier)
@@ -142,6 +143,7 @@ class CyclerDDC(Cycler):
142143
Names:
143144
144145
- Cycler DDC: Original name by Marc Harper
146+
- Periodic player DDC: [Mittal2009]_
145147
"""
146148
name = 'Cycler DDC'
147149
classifier = copy.copy(Cycler.classifier)

axelrod/strategies/defector.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ class Defector(Player):
1111
1212
- Defector: [Axelrod1984]_
1313
- ALLD: [Press2012]_
14+
- Always defect: [Mittal2009]_
1415
"""
1516

1617
name = 'Defector'
@@ -30,7 +31,12 @@ def strategy(opponent: Player) -> Action:
3031

3132

3233
class TrickyDefector(Player):
33-
"""A defector that is trying to be tricky."""
34+
"""A defector that is trying to be tricky.
35+
36+
Names:
37+
38+
- Tricky Defector: Original name by Karol Langner
39+
"""
3440

3541
name = "Tricky Defector"
3642
classifier = {

axelrod/strategies/forgiver.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,10 @@ class Forgiver(Player):
88
"""
99
A player starts by cooperating however will defect if at any point
1010
the opponent has defected more than 10 percent of the time
11+
12+
Names:
13+
14+
- Forgiver: Original name by Thomas Campbell
1115
"""
1216

1317
name = 'Forgiver'
@@ -36,6 +40,10 @@ class ForgivingTitForTat(Player):
3640
A player starts by cooperating however will defect if at any point, the
3741
opponent has defected more than 10 percent of the time, and their most
3842
recent decision was defect.
43+
44+
Names:
45+
46+
- Forgiving Tit For Tat: Original name by Thomas Campbell
3947
"""
4048

4149
name = 'Forgiving Tit For Tat'

axelrod/strategies/gambler.py

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,10 @@ class Gambler(LookerUp):
2020
"""
2121
A stochastic version of LookerUp which will select randomly an action in
2222
some cases.
23+
24+
Names:
25+
26+
- Gambler: Original name by Georgios Koutsovoulos
2327
"""
2428

2529
name = 'Gambler'
@@ -47,7 +51,8 @@ class PSOGamblerMem1(Gambler):
4751
Axelrod library.
4852
4953
Names:
50-
- PSO Gambler Mem1: Original name by Marc Harper
54+
55+
- PSO Gambler Mem1: Original name by Marc Harper
5156
"""
5257

5358
name = "PSO Gambler Mem1"
@@ -64,7 +69,8 @@ class PSOGambler1_1_1(Gambler):
6469
A 1x1x1 PSOGambler trained with pyswarm.
6570
6671
Names:
67-
- PSO Gambler 1_1_1: Original name by Marc Harper
72+
73+
- PSO Gambler 1_1_1: Original name by Marc Harper
6874
"""
6975

7076
name = "PSO Gambler 1_1_1"
@@ -78,10 +84,12 @@ def __init__(self) -> None:
7884

7985
class PSOGambler2_2_2(Gambler):
8086
"""
81-
A 2x2x2 PSOGambler trained with pyswarm. Original version by @GDKO.
87+
A 2x2x2 PSOGambler trained with a particle swarm algorithm (implemented in
88+
pyswarm). Original version by Georgios Koutsovoulos.
8289
8390
Names:
84-
- PSO Gambler 2_2_2: Original name by Marc Harper
91+
92+
- PSO Gambler 2_2_2: Original name by Marc Harper
8593
"""
8694

8795
name = "PSO Gambler 2_2_2"
@@ -98,8 +106,8 @@ class PSOGambler2_2_2_Noise05(Gambler):
98106
A 2x2x2 PSOGambler trained with pyswarm with noise=0.05.
99107
100108
Names:
101-
- PSO Gambler 2_2_2 Noise 05: Original name by Marc Harper
102109
110+
- PSO Gambler 2_2_2 Noise 05: Original name by Marc Harper
103111
"""
104112

105113
name = "PSO Gambler 2_2_2 Noise 05"

axelrod/strategies/geller.py

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ class Geller(Player):
1717
1818
If unable to do this: will play randomly.
1919
20-
Geller - by Martin Chorley (@martinjc), heavily inspired by Matthew Williams (@voxmjw)
2120
2221
This code is inspired by Matthew Williams' talk
2322
"Cheating at rock-paper-scissors — meta-programming in Python"
@@ -33,6 +32,10 @@ class Geller(Player):
3332
3433
This is almost certainly cheating, and more than likely against the
3534
spirit of the 'competition' :-)
35+
36+
Names:
37+
38+
- Geller: Original name by Martin Chorley (@martinjc)
3639
"""
3740

3841
name = 'Geller'
@@ -64,6 +67,10 @@ def strategy(self, opponent: Player) -> Action:
6467
class GellerCooperator(Geller):
6568
"""Observes what the payer will do (like :code:`Geller`) but if unable to
6669
will cooperate.
70+
71+
Names:
72+
73+
- Geller Cooperator: Original name by Karol Langner
6774
"""
6875
name = 'Geller Cooperator'
6976
classifier = {
@@ -78,13 +85,19 @@ class GellerCooperator(Geller):
7885

7986
@staticmethod
8087
def foil_strategy_inspection() -> Action:
81-
"""Foils _strategy_utils.inspect_strategy and _strategy_utils.look_ahead"""
88+
"""
89+
Foils _strategy_utils.inspect_strategy and _strategy_utils.look_ahead
90+
"""
8291
return C
8392

8493

8594
class GellerDefector(Geller):
8695
"""Observes what the payer will do (like :code:`Geller`) but if unable to
8796
will defect.
97+
98+
Names:
99+
100+
- Geller Defector: Original name by Karol Langner
88101
"""
89102
name = 'Geller Defector'
90103
classifier = {

axelrod/strategies/gobymajority.py

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,11 @@ class GoByMajority(Player):
1919
2020
An optional memory attribute will limit the number of turns remembered (by
2121
default this is 0)
22+
23+
Names:
24+
25+
- Go By Majority: [Axelrod1984]_
26+
- Soft Majority: [Mittal2009]_
2227
"""
2328

2429
name = 'Go By Majority'
@@ -86,6 +91,10 @@ def strategy(self, opponent: Player) -> Action:
8691
class GoByMajority40(GoByMajority):
8792
"""
8893
GoByMajority player with a memory of 40.
94+
95+
Names:
96+
97+
- Go By Majority 40: Original name by Karol Langner
8998
"""
9099
name = 'Go By Majority 40'
91100
classifier = copy.copy(GoByMajority.classifier)
@@ -98,6 +107,10 @@ def __init__(self) -> None:
98107
class GoByMajority20(GoByMajority):
99108
"""
100109
GoByMajority player with a memory of 20.
110+
111+
Names:
112+
113+
- Go By Majority 20: Original name by Karol Langner
101114
"""
102115
name = 'Go By Majority 20'
103116
classifier = copy.copy(GoByMajority.classifier)
@@ -110,6 +123,10 @@ def __init__(self) -> None:
110123
class GoByMajority10(GoByMajority):
111124
"""
112125
GoByMajority player with a memory of 10.
126+
127+
Names:
128+
129+
- Go By Majority 10: Original name by Karol Langner
113130
"""
114131
name = 'Go By Majority 10'
115132
classifier = copy.copy(GoByMajority.classifier)
@@ -122,6 +139,10 @@ def __init__(self) -> None:
122139
class GoByMajority5(GoByMajority):
123140
"""
124141
GoByMajority player with a memory of 5.
142+
143+
Names:
144+
145+
- Go By Majority 5: Original name by Karol Langner
125146
"""
126147
name = 'Go By Majority 5'
127148
classifier = copy.copy(GoByMajority.classifier)
@@ -138,6 +159,10 @@ class HardGoByMajority(GoByMajority):
138159
139160
An optional memory attribute will limit the number of turns remembered (by
140161
default this is 0)
162+
163+
Names:
164+
165+
- Hard Majority: [Mittal2009]_
141166
"""
142167
name = 'Hard Go By Majority'
143168

@@ -148,6 +173,10 @@ def __init__(self, memory_depth: Union[int, float] = float('inf')) -> None:
148173
class HardGoByMajority40(HardGoByMajority):
149174
"""
150175
HardGoByMajority player with a memory of 40.
176+
177+
Names:
178+
179+
- Hard Go By Majority 40: Original name by Karol Langner
151180
"""
152181
name = 'Hard Go By Majority 40'
153182
classifier = copy.copy(GoByMajority.classifier)
@@ -160,6 +189,10 @@ def __init__(self) -> None:
160189
class HardGoByMajority20(HardGoByMajority):
161190
"""
162191
HardGoByMajority player with a memory of 20.
192+
193+
Names:
194+
195+
- Hard Go By Majority 20: Original name by Karol Langner
163196
"""
164197
name = 'Hard Go By Majority 20'
165198
classifier = copy.copy(GoByMajority.classifier)
@@ -172,6 +205,10 @@ def __init__(self) -> None:
172205
class HardGoByMajority10(HardGoByMajority):
173206
"""
174207
HardGoByMajority player with a memory of 10.
208+
209+
Names:
210+
211+
- Hard Go By Majority 10: Original name by Karol Langner
175212
"""
176213
name = 'Hard Go By Majority 10'
177214
classifier = copy.copy(GoByMajority.classifier)
@@ -184,6 +221,10 @@ def __init__(self) -> None:
184221
class HardGoByMajority5(HardGoByMajority):
185222
"""
186223
HardGoByMajority player with a memory of 5.
224+
225+
Names:
226+
227+
- Hard Go By Majority 5: Original name by Karol Langner
187228
"""
188229
name = 'Hard Go By Majority 5'
189230
classifier = copy.copy(GoByMajority.classifier)

axelrod/strategies/grudger.py

Lines changed: 26 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,14 @@ def strategy(opponent: Player) -> Action:
3939

4040

4141
class ForgetfulGrudger(Player):
42-
"""A player starts by cooperating however will defect if at any point the
43-
opponent has defected, but forgets after mem_length matches."""
42+
"""
43+
A player starts by cooperating however will defect if at any point the
44+
opponent has defected, but forgets after mem_length matches.
45+
46+
Names:
47+
48+
- Forgetful Grudger: Original name by Geraint Palmer
49+
"""
4450

4551
name = 'Forgetful Grudger'
4652
classifier = {
@@ -83,8 +89,14 @@ def reset(self):
8389

8490

8591
class OppositeGrudger(Player):
86-
"""A player starts by defecting however will cooperate if at any point the
87-
opponent has cooperated."""
92+
"""
93+
A player starts by defecting however will cooperate if at any point the
94+
opponent has cooperated.
95+
96+
Names:
97+
98+
- Opposite Grudger: Original name by Geraint Palmer
99+
"""
88100

89101
name = 'Opposite Grudger'
90102
classifier = {
@@ -107,7 +119,13 @@ def strategy(opponent: Player) -> Action:
107119

108120

109121
class Aggravater(Player):
110-
"""Grudger, except that it defects on the first 3 turns"""
122+
"""
123+
Grudger, except that it defects on the first 3 turns
124+
125+
Names
126+
127+
Aggravater: Original name by Thomas Campbell
128+
"""
111129

112130
name = 'Aggravater'
113131
classifier = {
@@ -135,10 +153,7 @@ class SoftGrudger(Player):
135153
defecting: punishes by playing: D, D, D, D, C, C. (Will continue to
136154
cooperate afterwards).
137155
138-
For reference see: "Engineering Design of Strategies for Winning
139-
Iterated Prisoner's Dilemma Competitions" by Jiawei Li, Philip Hingston,
140-
and Graham Kendall. IEEE TRANSACTIONS ON COMPUTATIONAL INTELLIGENCE AND AI
141-
IN GAMES, VOL. 3, NO. 4, DECEMBER 2011
156+
- Soft Grudger (SGRIM): [Li2011]_
142157
"""
143158

144159
name = 'Soft Grudger'
@@ -218,7 +233,8 @@ class EasyGo(Player):
218233
219234
Names:
220235
221-
- Easy Go [Prison1998]_
236+
- Easy Go: [Prison1998]_
237+
- Reverse Grudger (RGRIM): [Li2011]_
222238
"""
223239

224240
name = 'EasyGo'

axelrod/strategies/grumpy.py

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

66

77
class Grumpy(Player):
8-
"""A player that defects after a certain level of grumpiness.
8+
"""
9+
A player that defects after a certain level of grumpiness.
910
Grumpiness increases when the opponent defects and decreases
10-
when the opponent co-operates."""
11+
when the opponent co-operates.
12+
13+
Names:
14+
15+
- Grumpy: Original name by Jason Young
16+
"""
1117

1218
name = 'Grumpy'
1319
classifier = {

0 commit comments

Comments
 (0)