Skip to content

Commit 3e16e83

Browse files
committed
Minor styling changes
1 parent 31e60df commit 3e16e83

File tree

1 file changed

+20
-11
lines changed

1 file changed

+20
-11
lines changed

axelrod/strategies/axelrod_second.py

Lines changed: 20 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -203,6 +203,7 @@ def strategy(self, opponent: Player) -> Action:
203203
# Play TFT
204204
return opponent.history[-1]
205205

206+
206207
class Tranquilizer(Player):
207208

208209
"""
@@ -468,6 +469,7 @@ def strategy(self, opponent: Player) -> Action:
468469
return C
469470
return D
470471

472+
471473
class Kluepfel(Player):
472474
"""
473475
Strategy submitted to Axelrod's second tournament by Charles Kluepfel
@@ -549,7 +551,7 @@ def strategy(self, opponent: Player) -> Action:
549551

550552
if one_move_ago == two_moves_ago and two_moves_ago == three_moves_ago:
551553
return one_move_ago
552-
554+
553555
r = random.random() # Everything following is stochastic
554556
if one_move_ago == two_moves_ago:
555557
if r < 0.9:
@@ -567,6 +569,7 @@ def strategy(self, opponent: Player) -> Action:
567569
else:
568570
return one_move_ago.flip()
569571

572+
570573
class Borufsen(Player):
571574
"""
572575
Strategy submitted to Axelrod's second tournament by Otto Borufsen
@@ -588,8 +591,8 @@ class Borufsen(Player):
588591
cooperate. (Doesn't block third rule.)
589592
3. Otherwise, do tit-for-tat.
590593
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
593596
conditions hold:
594597
595598
- Detected random: Opponent cooperated 7-18 times since last mode
@@ -689,7 +692,7 @@ def strategy(self, opponent: Player) -> Action:
689692
return D
690693
else:
691694
assert self.mode == "Normal"
692-
695+
693696
# Look for mutual defects
694697
if self.history[-1] == D and opponent.history[-1] == D:
695698
self.mutual_defect_streak += 1
@@ -699,7 +702,7 @@ def strategy(self, opponent: Player) -> Action:
699702
self.mutual_defect_streak = 0
700703
self.echo_streak = 0 # Reset both streaks.
701704
return self.try_return(C)
702-
705+
703706
# Look for echoes
704707
# Fortran code defaults two turns back to C if only second turn
705708
my_two_back, opp_two_back = C, C
@@ -719,6 +722,7 @@ def strategy(self, opponent: Player) -> Action:
719722
# Tit-for-tat
720723
return self.try_return(opponent.history[-1])
721724

725+
722726
class Cave(Player):
723727
"""
724728
Strategy submitted to Axelrod's second tournament by Rob Cave (K49R), and
@@ -756,13 +760,15 @@ def strategy(self, opponent: Player) -> Action:
756760
if turn == 1: return C
757761

758762
number_defects = opponent.defections
759-
# Size of numerator is smaller than denomator -- How it was in the Fortran.
760763
perc_defects = number_defects / turn
761764

762765
# 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
766772

767773
if opponent.history[-1] == D:
768774
if number_defects > 17:
@@ -772,6 +778,7 @@ def strategy(self, opponent: Player) -> Action:
772778
else:
773779
return C
774780

781+
775782
class WmAdams(Player):
776783
"""
777784
Strategy submitted to Axelrod's second tournament by William Adams (K44R),
@@ -854,10 +861,12 @@ def update_score(self, opponent: Player):
854861
self.own_score += game.score(last_round)[0]
855862

856863
def strategy(self, opponent: Player) -> Action:
857-
if self.mode == "Defect": return D
864+
if self.mode == "Defect":
865+
return D
858866

859867
turn = len(self.history) + 1
860-
if turn == 1: return C
868+
if turn == 1:
869+
return C
861870

862871
self.update_score(opponent)
863872

0 commit comments

Comments
 (0)