Skip to content

Commit 9a2aad4

Browse files
drvinceknightmarcharper
authored andcommitted
Remove more unnecessary utils.
1 parent 1025da1 commit 9a2aad4

File tree

3 files changed

+0
-66
lines changed

3 files changed

+0
-66
lines changed

axelrod/_strategy_utils.py

Lines changed: 0 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -69,30 +69,6 @@ def inspect_strategy(inspector, opponent):
6969
return opponent.strategy(inspector)
7070

7171

72-
def _limited_simulate_play(player_1, player_2, h1):
73-
"""Simulates a player's move.
74-
75-
After inspecting player_2's next move (allowing player_2's strategy
76-
method to set any internal variables as needed), update histories
77-
for both players. Note that player_1's move is an argument.
78-
79-
If you need a more complete simulation, see `simulate_play` in
80-
player.py.
81-
82-
Parameters
83-
----------
84-
player_1: Player
85-
The player whose move is already known.
86-
player_2: Player
87-
The player the we want to inspect.
88-
h1: Action
89-
The next action for first player.
90-
"""
91-
h2 = inspect_strategy(player_1, player_2)
92-
player_1.update_history(h1, h2)
93-
player_2.update_history(h2, h1)
94-
95-
9672
def _calculate_scores(p1, p2, game):
9773
"""Calculates the scores for two players based their history.
9874
@@ -118,42 +94,6 @@ def _calculate_scores(p1, p2, game):
11894
return s1, s2
11995

12096

121-
def look_ahead(player1, player2, game, rounds=10):
122-
"""Returns a constant action that maximizes score by looking ahead.
123-
124-
Parameters
125-
----------
126-
player_1: Player
127-
The player that will look ahead.
128-
player_2: Player
129-
The opponent that will be inspected.
130-
game: Game
131-
The Game object used to score rounds.
132-
rounds: int
133-
The number of rounds to look ahead.
134-
135-
Returns
136-
-------
137-
Action
138-
The action that maximized score if it is played constantly.
139-
"""
140-
results = {}
141-
possible_strategies = {C: Cooperator(), D: Defector()}
142-
for action, player in possible_strategies.items():
143-
# Instead of a deepcopy, create a new opponent and replay the history to it.
144-
opponent_ = player2.clone()
145-
if opponent_.classifier["stochastic"]:
146-
opponent_.set_seed(player2._seed)
147-
for h in player1.history:
148-
_limited_simulate_play(player, opponent_, h)
149-
150-
# Now play forward with the constant strategy.
151-
simulate_match(player, opponent_, action, rounds)
152-
results[action] = _calculate_scores(player, opponent_, game)
153-
154-
return C if results[C] > results[D] else D
155-
156-
15797
@lru_cache()
15898
def recursive_thue_morse(n):
15999
"""The recursive definition of the Thue-Morse sequence.

axelrod/strategies/darwin.py

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -54,11 +54,6 @@ def __init__(self) -> None:
5454
def receive_match_attributes(self):
5555
self.outcomes = self.match_attributes["game"].scores
5656

57-
@staticmethod
58-
def foil_strategy_inspection() -> Action:
59-
"""Foils _strategy_utils.inspect_strategy and _strategy_utils.look_ahead"""
60-
return C
61-
6257
def strategy(self, opponent: Player) -> Action:
6358
"""Actual strategy definition that determines player's action."""
6459
trial = len(self.history)

axelrod/tests/unit/test_strategy_utils.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
from axelrod._strategy_utils import (
66
detect_cycle,
77
inspect_strategy,
8-
look_ahead,
98
recursive_thue_morse,
109
thue_morse_generator,
1110
)

0 commit comments

Comments
 (0)