@@ -203,6 +203,7 @@ def strategy(self, opponent: Player) -> Action:
203
203
# Play TFT
204
204
return opponent .history [- 1 ]
205
205
206
+
206
207
class Tranquilizer (Player ):
207
208
208
209
"""
@@ -468,6 +469,7 @@ def strategy(self, opponent: Player) -> Action:
468
469
return C
469
470
return D
470
471
472
+
471
473
class Kluepfel (Player ):
472
474
"""
473
475
Strategy submitted to Axelrod's second tournament by Charles Kluepfel
@@ -549,7 +551,7 @@ def strategy(self, opponent: Player) -> Action:
549
551
550
552
if one_move_ago == two_moves_ago and two_moves_ago == three_moves_ago :
551
553
return one_move_ago
552
-
554
+
553
555
r = random .random () # Everything following is stochastic
554
556
if one_move_ago == two_moves_ago :
555
557
if r < 0.9 :
@@ -567,6 +569,7 @@ def strategy(self, opponent: Player) -> Action:
567
569
else :
568
570
return one_move_ago .flip ()
569
571
572
+
570
573
class Borufsen (Player ):
571
574
"""
572
575
Strategy submitted to Axelrod's second tournament by Otto Borufsen
@@ -588,8 +591,8 @@ class Borufsen(Player):
588
591
cooperate. (Doesn't block third rule.)
589
592
3. Otherwise, do tit-for-tat.
590
593
591
- Start in normal mode, but every 25 turns starting with the 27th turn,
592
- re-evaluate the mode. Enter defect mode if any of the following
594
+ Start in normal mode, but every 25 turns starting with the 27th turn,
595
+ re-evaluate the mode. Enter defect mode if any of the following
593
596
conditions hold:
594
597
595
598
- Detected random: Opponent cooperated 7-18 times since last mode
@@ -689,7 +692,7 @@ def strategy(self, opponent: Player) -> Action:
689
692
return D
690
693
else :
691
694
assert self .mode == "Normal"
692
-
695
+
693
696
# Look for mutual defects
694
697
if self .history [- 1 ] == D and opponent .history [- 1 ] == D :
695
698
self .mutual_defect_streak += 1
@@ -699,7 +702,7 @@ def strategy(self, opponent: Player) -> Action:
699
702
self .mutual_defect_streak = 0
700
703
self .echo_streak = 0 # Reset both streaks.
701
704
return self .try_return (C )
702
-
705
+
703
706
# Look for echoes
704
707
# Fortran code defaults two turns back to C if only second turn
705
708
my_two_back , opp_two_back = C , C
@@ -719,6 +722,7 @@ def strategy(self, opponent: Player) -> Action:
719
722
# Tit-for-tat
720
723
return self .try_return (opponent .history [- 1 ])
721
724
725
+
722
726
class Cave (Player ):
723
727
"""
724
728
Strategy submitted to Axelrod's second tournament by Rob Cave (K49R), and
@@ -756,13 +760,15 @@ def strategy(self, opponent: Player) -> Action:
756
760
if turn == 1 : return C
757
761
758
762
number_defects = opponent .defections
759
- # Size of numerator is smaller than denomator -- How it was in the Fortran.
760
763
perc_defects = number_defects / turn
761
764
762
765
# If overly defect or appears random
763
- if turn > 39 and perc_defects > 0.39 : return D
764
- if turn > 29 and perc_defects > 0.65 : return D
765
- if turn > 19 and perc_defects > 0.79 : return D
766
+ if turn > 39 and perc_defects > 0.39 :
767
+ return D
768
+ if turn > 29 and perc_defects > 0.65 :
769
+ return D
770
+ if turn > 19 and perc_defects > 0.79 :
771
+ return D
766
772
767
773
if opponent .history [- 1 ] == D :
768
774
if number_defects > 17 :
@@ -772,6 +778,7 @@ def strategy(self, opponent: Player) -> Action:
772
778
else :
773
779
return C
774
780
781
+
775
782
class WmAdams (Player ):
776
783
"""
777
784
Strategy submitted to Axelrod's second tournament by William Adams (K44R),
@@ -809,3 +816,67 @@ def strategy(self, opponent: Player) -> Action:
809
816
if number_defects > 9 and opponent .history [- 1 ] == D :
810
817
return random_choice ((0.5 ) ** (number_defects - 9 ))
811
818
return C
819
+
820
+ class GraaskampKatzen (Player ):
821
+ """
822
+ Strategy submitted to Axelrod's second tournament by Jim Graaskamp and Ken
823
+ Katzen (K60R), and came in sixth in that tournament.
824
+
825
+ Play Tit-for-Tat at first, and track own score. At select checkpoints,
826
+ check for a high score. Switch to Default Mode if:
827
+
828
+ - On move 11, score < 23
829
+ - On move 21, score < 53
830
+ - On move 31, score < 83
831
+ - On move 41, score < 113
832
+ - On move 51, score < 143
833
+ - On move 101, score < 293
834
+
835
+ Once in Defect Mode, defect forever.
836
+
837
+ Names:
838
+
839
+ - GraaskampKatzen: [Axelrod1980b]_
840
+ """
841
+
842
+ name = "GraaskampKatzen"
843
+ classifier = {
844
+ 'memory_depth' : float ('inf' ),
845
+ 'stochastic' : False ,
846
+ 'makes_use_of' : set (['game' ]),
847
+ 'long_run_time' : False ,
848
+ 'inspects_source' : False ,
849
+ 'manipulates_source' : False ,
850
+ 'manipulates_state' : False
851
+ }
852
+
853
+ def __init__ (self ):
854
+ super ().__init__ ()
855
+ self .own_score = 0
856
+ self .mode = "Normal"
857
+
858
+ def update_score (self , opponent : Player ):
859
+ game = self .match_attributes ["game" ]
860
+ last_round = (self .history [- 1 ], opponent .history [- 1 ])
861
+ self .own_score += game .score (last_round )[0 ]
862
+
863
+ def strategy (self , opponent : Player ) -> Action :
864
+ if self .mode == "Defect" :
865
+ return D
866
+
867
+ turn = len (self .history ) + 1
868
+ if turn == 1 :
869
+ return C
870
+
871
+ self .update_score (opponent )
872
+
873
+ if turn == 11 and self .own_score < 23 or \
874
+ turn == 21 and self .own_score < 53 or \
875
+ turn == 31 and self .own_score < 83 or \
876
+ turn == 41 and self .own_score < 113 or \
877
+ turn == 51 and self .own_score < 143 or \
878
+ turn == 101 and self .own_score < 293 :
879
+ self .mode = "Defect"
880
+ return D
881
+
882
+ return opponent .history [- 1 ] # Tit-for-Tat
0 commit comments