Skip to content

Commit 33c903f

Browse files
committed
Fix Nydegger.
1 parent d4e1552 commit 33c903f

File tree

4 files changed

+25
-9
lines changed

4 files changed

+25
-9
lines changed

axelrod/strategies/_strategies.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
FirstByGraaskamp,
1212
FirstByGrofman,
1313
FirstByJoss,
14-
Nydegger,
14+
FirstByNydegger,
1515
RevisedDowning,
1616
Shubik,
1717
SteinAndRapoport,
@@ -370,7 +370,7 @@
370370
Negation,
371371
NiceAverageCopier,
372372
NTitsForMTats,
373-
Nydegger,
373+
FirstByNydegger,
374374
OmegaTFT,
375375
OnceBitten,
376376
OppositeGrudger,

axelrod/strategies/axelrod_first.py

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -413,10 +413,26 @@ def __init__(self, p: float = 0.9) -> None:
413413
super().__init__(four_vector)
414414

415415

416-
class Nydegger(Player):
416+
class FirstByNydegger(Player):
417417
"""
418418
Submitted to Axelrod's first tournament by Rudy Nydegger.
419419
420+
The description written in [Axelrod1980]_ is:
421+
422+
> "The program begins with tit for tat for the first three moves, except
423+
> that if it was the only one to cooperate on the first move and the only one
424+
> to defect on the second move, it defects on the third move. After the third
425+
> move, its choice is determined from the 3 preceding outcomes in the
426+
> following manner. Let A be the sum formed by counting the other's defection
427+
> as 2 points and one's own as 1 point, and giving weights of 16, 4, and 1 to
428+
> the preceding three moves in chronological order. The choice can be
429+
> described as defecting only when A equals 1, 6, 7, 17, 22, 23, 26, 29, 30,
430+
> 31, 33, 38, 39, 45, 49, 54, 55, 58, or 61. Thus if all three preceding moves
431+
> are mutual defection, A = 63 and the rule cooperates. This rule was
432+
> designed for use in laboratory experiments as a stooge which had a memory
433+
> and appeared to be trustworthy, potentially cooperative, but not gullible
434+
> (Nydegger, 1978)."
435+
420436
The program begins with tit for tat for the first three moves, except
421437
that if it was the only one to cooperate on the first move and the only one
422438
to defect on the second move, it defects on the third move. After the
@@ -450,7 +466,7 @@ class Nydegger(Player):
450466
- Nydegger: [Axelrod1980]_
451467
"""
452468

453-
name = "Nydegger"
469+
name = "First tournament by Nydegger"
454470
classifier = {
455471
"memory_depth": 3,
456472
"stochastic": False,
@@ -462,7 +478,7 @@ class Nydegger(Player):
462478
}
463479

464480
def __init__(self) -> None:
465-
self.As = [1, 6, 7, 17, 22, 23, 26, 29, 30, 31, 33, 38, 39, 45, 54, 55, 58, 61]
481+
self.As = [1, 6, 7, 17, 22, 23, 26, 29, 30, 31, 33, 38, 39, 45, 49, 54, 55, 58, 61]
466482
self.score_map = {(C, C): 0, (C, D): 2, (D, C): 1, (D, D): 3}
467483
super().__init__()
468484

axelrod/tests/strategies/test_axelrod_first.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -304,10 +304,10 @@ def test_strategy(self):
304304
self.versus_test(axelrod.Defector(), expected_actions=actions, seed=2)
305305

306306

307-
class TestNydegger(TestPlayer):
307+
class TestFirstByNydegger(TestPlayer):
308308

309-
name = "Nydegger"
310-
player = axelrod.Nydegger
309+
name = "First tournament by Nydegger"
310+
player = axelrod.FirstByNydegger
311311
expected_classifier = {
312312
"memory_depth": 3,
313313
"stochastic": False,

docs/reference/overview_of_strategies.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ An indication is given as to whether or not this strategy is implemented in the
1818

1919
"Tit For Tat", "Anatol Rapoport", ":class:`TitForTat <axelrod.strategies.titfortat.TitForTat>`"
2020
"Tideman and Chieruzzi", "T Nicolaus Tideman and Paula Chieruzz", ":class:`TidemanAndChieruzzi <axelrod.strategies.axelrod_first.TidemanAndChieruzzi>`"
21-
"Nydegger", "Rudy Nydegger", ":class:`Nydegger <axelrod.strategies.axelrod_first.Nydegger>`"
21+
"Nydegger", "Rudy Nydegger", ":class:`Nydegger <axelrod.strategies.axelrod_first.FirstByNydegger>`"
2222
"Grofman", "Bernard Grofman", ":class:`Grofman <axelrod.strategies.axelrod_first.FirstByGrofman>`"
2323
"Shubik", "Martin Shubik", ":class:`Shubik <axelrod.strategies.axelrod_first.Shubik>`"
2424
"Stein and Rapoport", "Stein and Anatol Rapoport", ":class:`SteinAndRapoport <axelrod.strategies.axelrod_first.SteinAndRapoport>`"

0 commit comments

Comments
 (0)