Skip to content

Commit dc7a710

Browse files
committed
Modify Shubik.
Note that this was not the specific error that @id428 pointed out but having reviewed the papers and source code I found this one minor inaccuracy. @id428 made a point that the strategy should cooperate twice after it's round of retaliations but I do not see this in any of the descriptions of the strategy. Once the strategy has finished retaliating, all the texts indicate that it cooperates again but ready to retaliate.
1 parent eccd7e2 commit dc7a710

File tree

2 files changed

+28
-24
lines changed

2 files changed

+28
-24
lines changed

axelrod/strategies/axelrod_first.py

Lines changed: 27 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -600,17 +600,24 @@ class FirstByShubik(Player):
600600
> strategic implications in Shubik (1970). Further treatment of its is given
601601
> in Taylor (1976).
602602
603-
This is interpreted as:
604-
605-
Plays like Tit-For-Tat with the following modification. After each
606-
retaliation, the number of rounds that Shubik retaliates increases by 1.
603+
There is some room for interpretation as to how the strategy reacts to a
604+
defection on the turn where it starts to cooperate once more. In Shubik
605+
(1970) the strategy is described as:
606+
607+
> "I will play my move 1 to begin with and will continue to do so, so long
608+
> as my information shows that the other player has chosen his move 1. If my
609+
> information tells me he has used move 2, then I will use move 2 for the
610+
> immediate k subsequent periods, after which I will resume using move 1. If
611+
> he uses his move 2 again after I have resumed using move 1, then I will
612+
> switch to move 2 for the k + 1 immediately subsequent periods . . . and so
613+
> on, increasing my retaliation by an extra period for each departure from the
614+
> (1, 1) steady state."
607615
608-
# TODO Read
609-
# https://www.jstor.org/stable/pdf/173263.pdf?refreqid=excelsior%3A94cf485d88f107de1d72296c4cf5d988
610-
# as supposedely there there is description indicating that the strategy
611-
# would cooperate twice. I do not think I agree but need to check carefully.
616+
This is interpreted as:
612617
613-
This strategy came 5th in Axelrod's original tournament.
618+
The player cooperates, if when it is cooperating, the opponent defects it
619+
defects for k rounds. After k rounds it starts cooperating again and
620+
increments the value of k if the opponent defects again.
614621
615622
Names:
616623
@@ -645,24 +652,21 @@ def _decrease_retaliation_counter(self):
645652
def strategy(self, opponent: Player) -> Action:
646653
if not opponent.history:
647654
return C
648-
if opponent.history[-1] == D:
649-
# Retaliate against defections
650-
if self.history[-1] == C: # it's on now!
651-
# Lengthen the retaliation period
652-
self.is_retaliating = True
653-
self.retaliation_length += 1
654-
self.retaliation_remaining = self.retaliation_length
655-
self._decrease_retaliation_counter()
656-
return D
657-
else:
658-
# Just retaliate
659-
if self.is_retaliating:
660-
self._decrease_retaliation_counter()
661-
return D
655+
662656
if self.is_retaliating:
663657
# Are we retaliating still?
664658
self._decrease_retaliation_counter()
665659
return D
660+
661+
if opponent.history[-1] == D and self.history[-1] == C:
662+
# "If he uses his move 2 again after I have resumed using move 1,
663+
# then I will switch to move 2 for the k + 1 immediately subsequent
664+
# periods"
665+
self.is_retaliating = True
666+
self.retaliation_length += 1
667+
self.retaliation_remaining = self.retaliation_length
668+
self._decrease_retaliation_counter()
669+
return D
666670
return C
667671

668672

axelrod/tests/strategies/test_axelrod_first.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -392,7 +392,7 @@ def test_strategy(self):
392392
(D, D),
393393
(D, C),
394394
(D, D),
395-
(D, C),
395+
(C, C),
396396
]
397397
self.versus_test(opponent, expected_actions=actions)
398398

0 commit comments

Comments
 (0)