Skip to content

Commit ad6c40a

Browse files
drvinceknightmarcharper
authored andcommitted
Fun black autoformatter.
1 parent 9a05018 commit ad6c40a

File tree

2 files changed

+11
-4
lines changed

2 files changed

+11
-4
lines changed

axelrod/strategies/axelrod_first.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -268,7 +268,10 @@ def strategy(self, opponent: Player) -> Action:
268268

269269
if self.opponent_is_random:
270270
return D
271-
if all(opponent.history[i] == self.history[i - 1] for i in range(1, len(self.history))):
271+
if all(
272+
opponent.history[i] == self.history[i - 1]
273+
for i in range(1, len(self.history))
274+
):
272275
# Check if opponent plays Tit for Tat
273276
if opponent.history[-1] == D:
274277
return D
@@ -278,7 +281,8 @@ def strategy(self, opponent: Player) -> Action:
278281
self.next_random_defection_turn = random.randint(5, 15) + len(self.history)
279282

280283
if len(self.history) == self.next_random_defection_turn:
281-
self.next_random_defection_turn = random.randint(5, 15) + len(self.history) # resample the next defection turn
284+
# resample the next defection turn
285+
self.next_random_defection_turn = random.randint(5, 15) + len(self.history)
282286
return D
283287
return C
284288

axelrod/tests/strategies/test_axelrod_first.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -217,9 +217,12 @@ def test_strategy(self):
217217
)
218218

219219
# Test versus TfT
220-
expected_attrs = {"opponent_is_random": False, "next_random_defection_turn": None}
220+
expected_attrs = {
221+
"opponent_is_random": False,
222+
"next_random_defection_turn": None,
223+
}
221224
actions = [(C, C)] * 50 + [(D, C)] # 51 turns
222-
actions += [(C, D), (D, C)] * 3 # 56 turns
225+
actions += [(C, D), (D, C)] * 3 # 56 turns
223226
actions += [(C, D), (D, C)] * 50
224227
self.versus_test(
225228
axelrod.TitForTat(), expected_actions=actions, seed=0, attrs=expected_attrs

0 commit comments

Comments
 (0)