Skip to content

Commit 5e5fa9a

Browse files
yohmmarcharper
authored andcommitted
add reference and docstrings
1 parent df150d3 commit 5e5fa9a

File tree

2 files changed

+13
-7
lines changed

2 files changed

+13
-7
lines changed

axelrod/strategies/grudger.py

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -346,16 +346,20 @@ def strategy(opponent: Player) -> Action:
346346

347347
class CAPRI(Player):
348348
"""
349-
CAPRI is a strategy whose behavior is defined by the following five rules.
350-
C: Cooperate at mutual cooperation
351-
A: Accept punishmentl
352-
P: Punish
353-
R: Recover
354-
I: In all ohter cases, defect.
349+
CAPRI is a memory-3 strategy proposed in [Murase2020]_. Its behavior is defined by the following five rules.
350+
C: Cooperate at mutual cooperation.
351+
This rule prescribes c at (ccc, ccc).
352+
A: Accept punishment when you mistakenly defected from mutual cooperation.
353+
This rule prescribes c at (ccd, ccc), (cdc, ccd), (dcc, cdc), and (ccc, dcc).
354+
P: Punish your co-player by defecting once when he defected from mutual cooperation.
355+
This rule prescribes d at (ccc, ccd), and then c at (ccd, cdc), (cdc, dcc), and (dcc, ccc).
356+
R: Recover cooperation when you or your co-player cooperated at mutual defection.
357+
This rule prescribes c at (ddd, ddc), (ddc, dcc), (dcc, ccc), (ddc, ddd), (dcc, ddc), (ccc, dcc), (ddc, ddc), and (dcc, dcc).
358+
I: In all the ohter cases, defect.
355359
356360
Names:
357361
358-
- CAPRI: Original Name by Y. Murase et al. [Murase 2020]
362+
- CAPRI: Original Name by Y. Murase et al. [Murase2020]_
359363
"""
360364

361365
name = "CAPRI"
@@ -369,6 +373,7 @@ class CAPRI(Player):
369373
}
370374

371375
def strategy(self, opponent: Player) -> Action:
376+
# initial history profile is full cooperation
372377
hist = [[C,C],[C,C],[C,C]]
373378
for i in range(min(len(self.history), 3)):
374379
hist[-i-1][0] = self.history[-i-1]

docs/reference/bibliography.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ documentation.
4646
for the Iterated Prisoner's Dilemma. Proceedings of the 2015
4747
International Conference on Autonomous Agents and Multiagent Systems.
4848
.. [Mittal2009] Mittal, S., & Deb, K. (2009). Optimal strategies of the iterated prisoner’s dilemma problem for multiple conflicting objectives. IEEE Transactions on Evolutionary Computation, 13(3), 554–565. https://doi.org/10.1109/TEVC.2008.2009459
49+
.. [Murase2020] Murase, Y., & Baek, S.K. (2020). Five Rules for Friendly Rivalry in Direct Reciprocity. Scientific Reports 10:16904 https://doi.org/10.1038/s41598-020-73855-x
4950
.. [Nachbar1992] Nachbar J., Evolution in the finitely repeated prisoner’s dilemma, Journal of Economic Behavior & Organization, 19(3): 307-326, 1992.
5051
.. [NC2019] https://github.com/ncase/trust (Accessed: 30 October 2019)
5152
.. [Nowak1989] Nowak, Martin, and Karl Sigmund. "Game-dynamical aspects of the prisoner's dilemma." Applied Mathematics and Computation 30.3 (1989): 191-213.

0 commit comments

Comments
 (0)