Skip to content

Commit 5e4f4c8

Browse files
committed
Minor formatting/comment fixes.
1 parent d902e41 commit 5e4f4c8

File tree

1 file changed

+14
-14
lines changed

1 file changed

+14
-14
lines changed

axelrod/strategies/axelrod_second.py

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -979,10 +979,11 @@ def strategy(self, opponent: Player) -> Action:
979979

980980
class Harrington(Player):
981981
"""
982-
Strategy submitted to Axelrod's second tournament by Paul Harringtn (K75R),
982+
Strategy submitted to Axelrod's second tournament by Paul Harrington (K75R)
983983
and came in eighth in that tournament.
984984
985-
This strategy has three modes: Normal, and Fair-weather, Defect.
985+
This strategy has three modes: Normal, Fair-weather, and Defect. These
986+
mode names were not present in Harrington's submission.
986987
987988
In Normal and Fair-weather modes, the strategy begins by:
988989
@@ -1013,13 +1014,17 @@ class Harrington(Player):
10131014
The player mostly plays Tit-for-Tat for the first 36 moves, then defects on
10141015
the 37th move. If the opponent cooperates on the first 36 moves, and
10151016
defects on the 37th move also, then enter Fair-weather mode and cooperate
1016-
this turn.
1017+
this turn. Entering Fair-weather mode is extremely rare, since this can
1018+
only happen if the opponent cooperates for the first 36 then defects
1019+
unprovoked on the 37th. (That is, this player's first 36 moves are also
1020+
Cooperations, so there's nothing really to trigger an opponent Defection.)
10171021
10181022
Next in Normal Mode:
10191023
10201024
1. Check for defect and parity streaks.
10211025
2. Check if cooperations are scheduled.
10221026
3. Otherwise,
1027+
10231028
- If turn < 37, Tit-for-Tat.
10241029
- If turn = 37, defect, mark this move as generous, and schedule two
10251030
more cooperations**.
@@ -1224,10 +1229,6 @@ def strategy(self, opponent: Player) -> Action:
12241229

12251230
if turn == 38 and opponent.history[-1] == D and opponent.cooperations == 36:
12261231
self.mode = "Fair-weather"
1227-
# These flags would already be set from turn == 37 logic below.
1228-
# Just take care to not lower this turn.
1229-
# self.more_coop = 2
1230-
# self.generous_n_turns_ago = 1 # 1 turn ago since this turn is ending.
12311232
return self.try_return(to_return=C, lower_flags=False)
12321233

12331234

@@ -1256,13 +1257,12 @@ def strategy(self, opponent: Player) -> Action:
12561257

12571258
if turn < 37:
12581259
return self.try_return(opponent.history[-1], inc_parity=True)
1259-
elif turn == 37:
1260+
if turn == 37:
12601261
self.more_coop, self.generous_n_turns_ago = 2, 1
12611262
return self.try_return(D, lower_flags=False)
1263+
if self.burned or random.random() > self.prob:
1264+
return self.try_return(opponent.history[-1], inc_parity=True)
12621265
else:
1263-
if self.burned or random.random() > self.prob:
1264-
return self.try_return(opponent.history[-1], inc_parity=True)
1265-
else:
1266-
self.prob += 0.05
1267-
self.more_coop, self.generous_n_turns_ago = 2, 1
1268-
return self.try_return(D, lower_flags=False)
1266+
self.prob += 0.05
1267+
self.more_coop, self.generous_n_turns_ago = 2, 1
1268+
return self.try_return(D, lower_flags=False)

0 commit comments

Comments
 (0)