Skip to content

Commit 3dc60fb

Browse files
committed
Rename and fix Tullock.
I believe the logic was slightly faulty for Tullock: the first 11 moves was correct however once past there we should only be considering the 10 previous moves.
1 parent aa417a1 commit 3dc60fb

File tree

4 files changed

+24
-13
lines changed

4 files changed

+24
-13
lines changed

axelrod/strategies/_strategies.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
FirstByShubik,
1717
SteinAndRapoport,
1818
TidemanAndChieruzzi,
19-
Tullock,
19+
FirstByTullock,
2020
UnnamedStrategy,
2121
)
2222
from .axelrod_second import (
@@ -430,7 +430,7 @@
430430
TrickyCooperator,
431431
TrickyDefector,
432432
TrickyLevelPunisher,
433-
Tullock,
433+
FirstByTullock,
434434
TwoTitsForTat,
435435
UsuallyCooperates,
436436
UsuallyDefects,

axelrod/strategies/axelrod_first.py

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -593,12 +593,23 @@ def strategy(self, opponent: Player) -> Action:
593593
return C
594594

595595

596-
class Tullock(Player):
596+
class FirstByTullock(Player):
597597
"""
598598
Submitted to Axelrod's first tournament by Gordon Tullock.
599599
600+
The description written in [Axelrod1980]_ is:
601+
602+
> "This rule cooperates on the first eleven moves. It then cooperates 10%
603+
> less than the other player has cooperated on the preceding ten moves. This
604+
> rule is based on an idea developed in Overcast and Tullock (1971). Professor
605+
> Tullock was invited to specify how the idea could be implemented, and he did
606+
> so out of scientific interest rather than an expectation that it would be a
607+
> likely winner."
608+
609+
This is interpreted as:
610+
600611
Cooperates for the first 11 rounds then randomly cooperates 10% less often
601-
than the opponent has in previous rounds.
612+
than the opponent has in the previous 10 rounds.
602613
603614
This strategy came 13th in Axelrod's original tournament.
604615
@@ -607,9 +618,9 @@ class Tullock(Player):
607618
- Tullock: [Axelrod1980]_
608619
"""
609620

610-
name = "Tullock"
621+
name = "First tournament by Tullock"
611622
classifier = {
612-
"memory_depth": 11, # long memory, modified by init
623+
"memory_depth": 11,
613624
"stochastic": True,
614625
"makes_use_of": set(),
615626
"long_run_time": False,
@@ -622,17 +633,17 @@ def __init__(self, rounds_to_cooperate: int = 11) -> None:
622633
"""
623634
Parameters
624635
----------
625-
rounds_to_cooperate: int, 10
636+
rounds_to_cooperate: int
626637
The number of rounds to cooperate initially
627638
"""
628639
super().__init__()
629640
self._rounds_to_cooperate = rounds_to_cooperate
630641
self.memory_depth = rounds_to_cooperate
631642

632643
def strategy(self, opponent: Player) -> Action:
633-
rounds = self._rounds_to_cooperate
634-
if len(self.history) < rounds:
644+
if len(self.history) < self._rounds_to_cooperate:
635645
return C
646+
rounds = self._rounds_to_cooperate - 1
636647
cooperate_count = opponent.history[-rounds:].count(C)
637648
prop_cooperate = cooperate_count / rounds
638649
prob_cooperate = max(0, prop_cooperate - 0.10)

axelrod/tests/strategies/test_axelrod_first.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -404,10 +404,10 @@ def test_strategy(self):
404404
self.versus_test(opponent, expected_actions=actions)
405405

406406

407-
class TestTullock(TestPlayer):
407+
class TestFirstByTullock(TestPlayer):
408408

409-
name = "Tullock: 11"
410-
player = axelrod.Tullock
409+
name = "First tournament by Tullock: 11"
410+
player = axelrod.FirstByTullock
411411
expected_classifier = {
412412
"memory_depth": 11,
413413
"stochastic": True,

docs/reference/overview_of_strategies.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ An indication is given as to whether or not this strategy is implemented in the
2828
"Downing", "Leslie Downing", ":class:`RevisedDowning <axelrod.strategies.axelrod_first.RevisedDowning>`"
2929
"Feld", "Scott Feld", ":class:`Feld <axelrod.strategies.axelrod_first.FirstByFeld>`"
3030
"Joss", "Johann Joss", ":class:`Joss <axelrod.strategies.axelrod_first.FirstByJoss>`"
31-
"Tullock", "Gordon Tullock", ":class:`Tullock <axelrod.strategies.axelrod_first.Tullock>`"
31+
"Tullock", "Gordon Tullock", ":class:`Tullock <axelrod.strategies.axelrod_first.FirstByTullock>`"
3232
"Unnamed Strategy", "Unknown", ":class:`UnnamedStrategy <axelrod.strategies.axelrod_first.UnnamedStrategy>`"
3333
"Random", "Unknownd", ":class:`Random <axelrod.strategies.rand.Random>`"
3434

0 commit comments

Comments
 (0)