Skip to content

Commit da80753

Browse files
committed
Minor formatting fixes.
1 parent 90c529b commit da80753

File tree

2 files changed

+33
-27
lines changed

2 files changed

+33
-27
lines changed

axelrod/strategies/axelrod_second.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -777,9 +777,9 @@ class WmAdams(Player):
777777
Strategy submitted to Axelrod's second tournament by William Adams (K44R),
778778
and came in fifth in that tournament.
779779
780-
Count the number of opponent defections after their first move, call
780+
Count the number of opponent defections after their first move, call
781781
`c_defect`. Defect if c_defect equals 4, 7, or 9. If c_defect > 9,
782-
then defect immediately after opponent defects with probability =
782+
then defect immediately after opponent defects with probability =
783783
(0.5)^(c_defect-1). Otherwise cooperate.
784784
785785
Names:

axelrod/tests/strategies/test_axelrod_second.py

Lines changed: 31 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -442,14 +442,15 @@ def test_strategy(self):
442442

443443
# Now we have to test the detect-random logic, which doesn't pick up
444444
# until after 26 turns. So we need a big sample.
445-
actions = [(C, D), (D, D), (D, D), (D, D), (D, D), (D, C), (C, C), (C, D),
446-
(C, C), (D, D), (D, C), (C, C), (C, D), (D, D), (C, D), (D, D),
447-
(D, C), (C, C), (D, C), (C, C), (C, D), (D, D), (D, C), (C, D),
448-
(D, C), (C, C), (C, D),
445+
actions = [(C, D), (D, D), (D, D), (D, D), (D, D), (D, C), (C, C),
446+
(C, D), (C, C), (D, D), (D, C), (C, C), (C, D), (D, D),
447+
(C, D), (D, D), (D, C), (C, C), (D, C), (C, C), (C, D),
448+
(D, D), (D, C), (C, D), (D, C), (C, C), (C, D),
449449
# Success detect random opponent for remaining turns.
450-
(D, D),(D, D),(D, D),(D, C),(D, D),(D, C),(D, D),(D, C),(D, D),
451-
(D, C),(D, C),(D, D),(D, D),(D, C),(D, C),(D, C),(D, C),(D, D),
452-
(D, C),(D, C),(D, C),(D, C),(D, D)]
450+
(D, D), (D, D), (D, D), (D, C), (D, D), (D, C), (D, D),
451+
(D, C), (D, D), (D, C), (D, C), (D, D), (D, D), (D, C),
452+
(D, C), (D, C), (D, C), (D, D), (D, C), (D, C), (D, C),
453+
(D, C), (D, D)]
453454
self.versus_test(axelrod.Random(0.5), expected_actions=actions, seed=10)
454455

455456
class TestBorufsen(TestPlayer):
@@ -475,16 +476,21 @@ def test_strategy(self):
475476
self.versus_test(axelrod.Defector(), expected_actions=actions)
476477

477478
# Alternates with additional coop, every sixth turn
478-
# Won't be labeled as random, since 2/3 of opponent's C follow player's C
479-
# `flip_next_defect` will get set on the sixth turn, which changes the seventh action
479+
# Won't be labeled as random, since 2/3 of opponent's C follow
480+
# player's C
481+
# `flip_next_defect` will get set on the sixth turn, which changes the
482+
# seventh action
480483
# Note that the first two turns of each period of six aren't
481-
# marked as echoes, and the third isn't marked that way until the fourth turn.
484+
# marked as echoes, and the third isn't marked that way until the
485+
# fourth turn.
482486
actions = [(C, C), (C, D), (D, C), (C, D), (D, C), (C, D)] * 20
483487
self.versus_test(axelrod.Alternator(), expected_actions=actions)
484488

485489
# Basically does tit-for-tat against Win-Shift, Lose-Stay D
486-
# After 26 turns, will detect random since half of opponent's C follow Cs
487-
# Coming out of it, there will be new pattern. Then random is detected again.
490+
# After 26 turns, will detect random since half of opponent's C follow
491+
# Cs
492+
# Coming out of it, there will be new pattern. Then random is detected
493+
# again.
488494
actions = [(C, D), (D, C), (C, C)] * 8 + \
489495
[(C, D), (D, C)] + [(D, C)] * 25 + \
490496
[(D, C)] + [(C, C), (C, D), (D, C)] * 8 + \
@@ -505,7 +511,7 @@ class TestCave(TestPlayer):
505511
}
506512

507513
def test_strategy(self):
508-
actions = [(C, C)] * 100
514+
actions = [(C, C)] * 100
509515
self.versus_test(axelrod.Cooperator(), expected_actions=actions)
510516

511517
# It will take until turn 18 to respond decide to repond D->D
@@ -531,16 +537,16 @@ def test_strategy(self):
531537

532538
#Here it will take until turn 40 to detect random and defect
533539
actions = [(C, C)]
534-
actions += [(C, D), (D, C), (C, D), (D, C), (C, D), (C, C), (C, D),
535-
(C, C), (C, D), (D, C), (C, D), (D, C), (C, D), (D, C),
536-
(C, D), (C, C), (C, D), (D, C), (C, D), (D, C), (C, D),
537-
(D, C), (C, D), (C, C), (C, D), (C, C), (C, D), (C, C),
538-
(C, D), (D, C), (C, D), (D, C), (C, D), (D, C), (C, D)] #Randomly choose
540+
actions += [(C, D), (D, C), (C, D), (D, C), (C, D), (C, C), (C, D),
541+
(C, C), (C, D), (D, C), (C, D), (D, C), (C, D), (D, C),
542+
(C, D), (C, C), (C, D), (D, C), (C, D), (D, C), (C, D),
543+
(D, C), (C, D), (C, C), (C, D), (C, C), (C, D), (C, C),
544+
(C, D), (D, C), (C, D), (D, C), (C, D), (D, C), (C, D)] #Randomly choose
539545
actions += [(D, C), (C, D), (D, C)] # 17 D have come, so tit for tat for a while
540546
actions += [(D, D), (D, C)] * 100 # Random finally detected
541547
self.versus_test(axelrod.Alternator(), expected_actions=actions, seed=2)
542548

543-
class TestCave(TestPlayer):
549+
class TestWmAdams(TestPlayer):
544550
name = "WmAdams"
545551
player = axelrod.WmAdams
546552
expected_classifier = {
@@ -564,18 +570,18 @@ def test_strategy(self):
564570
self.versus_test(defect_four, expected_actions=actions)
565571

566572
actions = [(C, D), (C, D), (C, D), (C, D), (C, D), (D, D), (C, D),
567-
(C, D), (D, D), (C, D), (D, D), (C, D), (D, D), (D, D),
568-
(D, D), (D, D)]
573+
(C, D), (D, D), (C, D), (D, D), (C, D), (D, D), (D, D),
574+
(D, D), (D, D)]
569575
self.versus_test(axelrod.Defector(), expected_actions=actions, seed=1)
570576
actions = [(C, D), (C, D), (C, D), (C, D), (C, D), (D, D), (C, D),
571-
(C, D), (D, D), (C, D), (D, D), (D, D), (D, D), (C, D),
572-
(D, D), (D, D)]
577+
(C, D), (D, D), (C, D), (D, D), (D, D), (D, D), (C, D),
578+
(D, D), (D, D)]
573579
self.versus_test(axelrod.Defector(), expected_actions=actions, seed=2)
574580

575581
# After responding to the 11th D (counted as 10 D), just start cooperating
576582
opponent_actions = [D] * 11 + [C] * 100
577583
changed_man = axelrod.MockPlayer(actions=opponent_actions)
578584
actions = [(C, D), (C, D), (C, D), (C, D), (C, D), (D, D), (C, D),
579-
(C, D), (D, D), (C, D), (D, D), (C, C)]
580-
actions += [(C,C)] * 99
585+
(C, D), (D, D), (C, D), (D, D), (C, C)]
586+
actions += [(C, C)] * 99
581587
self.versus_test(changed_man, expected_actions=actions, seed=1)

0 commit comments

Comments
 (0)