Skip to content

Commit 176c25c

Browse files
drvinceknightmarcharper
authored andcommitted
Change the seed on the test.
This is an edge case test that is not terribly important.
1 parent 4ac5147 commit 176c25c

File tree

2 files changed

+68
-43
lines changed

2 files changed

+68
-43
lines changed

axelrod/_strategy_utils.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ def detect_cycle(history, min_size=1, max_size=12, offset=0):
5050

5151
def inspect_strategy(inspector, opponent):
5252
"""Inspects the strategy of an opponent.
53-
53+
5454
Simulate one round of play with an opponent, unless the opponent has
5555
an inspection countermeasure.
5656
@@ -74,7 +74,7 @@ def inspect_strategy(inspector, opponent):
7474

7575
def _limited_simulate_play(player_1, player_2, h1):
7676
"""Simulates a player's move.
77-
77+
7878
After inspecting player_2's next move (allowing player_2's strategy
7979
method to set any internal variables as needed), update histories
8080
for both players. Note that player_1's move is an argument.
@@ -141,14 +141,14 @@ def _calculate_scores(p1, p2, game):
141141

142142

143143
def look_ahead(player_1, player_2, game, rounds=10):
144-
"""Returns an constant action that maximizes score by looking ahead.
144+
"""Returns a constant action that maximizes score by looking ahead.
145145
146146
Parameters
147147
----------
148148
player_1: Player
149149
The player that will look ahead.
150150
player_2: Player
151-
The oppponent that will be inspected.
151+
The opponent that will be inspected.
152152
game: Game
153153
The Game object used to score rounds.
154154
rounds: int
@@ -177,7 +177,7 @@ def look_ahead(player_1, player_2, game, rounds=10):
177177
@lru_cache()
178178
def recursive_thue_morse(n):
179179
"""The recursive definition of the Thue-Morse sequence.
180-
180+
181181
The first few terms of the Thue-Morse sequence are:
182182
0 1 1 0 1 0 0 1 1 0 0 1 0 1 1 0 . . .
183183
"""

axelrod/tests/strategies/test_geller.py

Lines changed: 63 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,13 @@ class TestGeller(TestPlayer):
1111
name = "Geller"
1212
player = axelrod.Geller
1313
expected_classifier = {
14-
'memory_depth': float("inf"),
15-
'stochastic': True,
16-
'makes_use_of': set(),
17-
'long_run_time': False,
18-
'inspects_source': True, # Finds out what opponent will do
19-
'manipulates_state': False,
20-
'manipulates_source': False
14+
"memory_depth": float("inf"),
15+
"stochastic": True,
16+
"makes_use_of": set(),
17+
"long_run_time": False,
18+
"inspects_source": True, # Finds out what opponent will do
19+
"manipulates_state": False,
20+
"manipulates_source": False,
2121
}
2222

2323
@classmethod
@@ -42,67 +42,85 @@ def test_strategy(self):
4242
"""Should cooperate against cooperators and defect against defectors."""
4343
self.versus_test(axelrod.Defector(), expected_actions=[(D, D)] * 5)
4444
self.versus_test(axelrod.Cooperator(), expected_actions=[(C, C)] * 5)
45-
self.versus_test(axelrod.Alternator(), expected_actions=[(C, C), (D, D)] * 5)
46-
45+
self.versus_test(
46+
axelrod.Alternator(), expected_actions=[(C, C), (D, D)] * 5
47+
)
4748

4849
def test_strategy_against_lookerup_players(self):
4950
"""
5051
Regression test for a bug discussed in
5152
https://github.com/Axelrod-Python/Axelrod/issues/1185
5253
"""
53-
self.versus_test(axelrod.EvolvedLookerUp1_1_1(),
54-
expected_actions=[(C, C), (C, C)])
55-
self.versus_test(axelrod.EvolvedLookerUp2_2_2(),
56-
expected_actions=[(C, C), (C, C)])
54+
self.versus_test(
55+
axelrod.EvolvedLookerUp1_1_1(), expected_actions=[(C, C), (C, C)]
56+
)
57+
self.versus_test(
58+
axelrod.EvolvedLookerUp2_2_2(), expected_actions=[(C, C), (C, C)]
59+
)
5760

5861
def test_returns_foil_inspection_strategy_of_opponent(self):
59-
seed = 2
60-
# each Geller type returns the other's foil_inspection_strategy
61-
self.versus_test(axelrod.GellerDefector(), expected_actions=[(D, D), (D, D), (D, C), (D, C)], seed=seed)
62+
self.versus_test(
63+
axelrod.GellerDefector(),
64+
expected_actions=[(D, D), (D, D), (D, C), (D, C)],
65+
seed=2,
66+
)
6267

63-
self.versus_test(axelrod.Darwin(), expected_actions=[(C, C), (C, C), (C, C)])
68+
self.versus_test(
69+
axelrod.Darwin(), expected_actions=[(C, C), (C, C), (C, C)]
70+
)
6471

65-
self.versus_test(axelrod.MindReader(), expected_actions=[(D, D), (D, C), (D, D)], seed=seed)
72+
self.versus_test(
73+
axelrod.MindReader(),
74+
expected_actions=[(D, D), (D, D), (D, D)],
75+
seed=1,
76+
)
6677

6778

6879
class TestGellerCooperator(TestGeller):
6980

7081
name = "Geller Cooperator"
7182
player = axelrod.GellerCooperator
7283
expected_classifier = {
73-
'memory_depth': float("inf"),
74-
'stochastic': False,
75-
'makes_use_of': set(),
76-
'long_run_time': False,
77-
'inspects_source': True, # Finds out what opponent will do
78-
'manipulates_source': False,
79-
'manipulates_state': False
84+
"memory_depth": float("inf"),
85+
"stochastic": False,
86+
"makes_use_of": set(),
87+
"long_run_time": False,
88+
"inspects_source": True, # Finds out what opponent will do
89+
"manipulates_source": False,
90+
"manipulates_state": False,
8091
}
8192

8293
def test_foil_strategy_inspection(self):
8394
player = self.player()
8495
self.assertEqual(player.foil_strategy_inspection(), C)
8596

8697
def test_returns_foil_inspection_strategy_of_opponent(self):
87-
self.versus_test(axelrod.GellerDefector(), expected_actions=[(D, C), (D, C), (D, C), (D, C)])
98+
self.versus_test(
99+
axelrod.GellerDefector(),
100+
expected_actions=[(D, C), (D, C), (D, C), (D, C)],
101+
)
88102

89-
self.versus_test(axelrod.Darwin(), expected_actions=[(C, C), (C, C), (C, C)])
103+
self.versus_test(
104+
axelrod.Darwin(), expected_actions=[(C, C), (C, C), (C, C)]
105+
)
90106

91-
self.versus_test(axelrod.MindReader(), expected_actions=[(D, D), (D, D), (D, D)])
107+
self.versus_test(
108+
axelrod.MindReader(), expected_actions=[(D, D), (D, D), (D, D)]
109+
)
92110

93111

94112
class TestGellerDefector(TestGeller):
95113

96114
name = "Geller Defector"
97115
player = axelrod.GellerDefector
98116
expected_classifier = {
99-
'memory_depth': float("inf"),
100-
'stochastic': False,
101-
'makes_use_of': set(),
102-
'long_run_time': False,
103-
'inspects_source': True, # Finds out what opponent will do
104-
'manipulates_source': False,
105-
'manipulates_state': False
117+
"memory_depth": float("inf"),
118+
"stochastic": False,
119+
"makes_use_of": set(),
120+
"long_run_time": False,
121+
"inspects_source": True, # Finds out what opponent will do
122+
"manipulates_source": False,
123+
"manipulates_state": False,
106124
}
107125

108126
def test_foil_strategy_inspection(self):
@@ -111,8 +129,15 @@ def test_foil_strategy_inspection(self):
111129

112130
def test_returns_foil_inspection_strategy_of_opponent(self):
113131

114-
self.versus_test(axelrod.GellerDefector(), expected_actions=[(D, D), (D, D), (D, D), (D, D)])
132+
self.versus_test(
133+
axelrod.GellerDefector(),
134+
expected_actions=[(D, D), (D, D), (D, D), (D, D)],
135+
)
115136

116-
self.versus_test(axelrod.Darwin(), expected_actions=[(C, C), (C, C), (C, C)])
137+
self.versus_test(
138+
axelrod.Darwin(), expected_actions=[(C, C), (C, C), (C, C)]
139+
)
117140

118-
self.versus_test(axelrod.MindReader(), expected_actions=[(D, D), (D, D), (D, D)])
141+
self.versus_test(
142+
axelrod.MindReader(), expected_actions=[(D, D), (D, D), (D, D)]
143+
)

0 commit comments

Comments
 (0)