Skip to content

Commit

Permalink
Remove further unused utils.
Browse files Browse the repository at this point in the history
  • Loading branch information
drvinceknight authored and marcharper committed May 24, 2021
1 parent 4c0ada7 commit 353bf46
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 66 deletions.
49 changes: 0 additions & 49 deletions axelrod/_strategy_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,55 +45,6 @@ def detect_cycle(history, min_size=1, max_size=12, offset=0):
return None


def inspect_strategy(inspector, opponent):
"""Inspects the strategy of an opponent.
Simulate one round of play with an opponent, unless the opponent has
an inspection countermeasure.
Parameters
----------
inspector: Player
The player doing the inspecting
opponent: Player
The player being inspected
Returns
-------
Action
The action that would be taken by the opponent.
"""
if hasattr(opponent, "foil_strategy_inspection"):
return opponent.foil_strategy_inspection()
else:
return opponent.strategy(inspector)


def _calculate_scores(p1, p2, game):
"""Calculates the scores for two players based their history.
Parameters
----------
p1: Player
The first player.
p2: Player
The second player.
game: Game
Game object used to score rounds in the players' histories.
Returns
-------
int, int
The scores for the two input players.
"""
s1, s2 = 0, 0
for pair in zip(p1.history, p2.history):
score = game.score(pair)
s1 += score[0]
s2 += score[1]
return s1, s2


@lru_cache()
def recursive_thue_morse(n):
"""The recursive definition of the Thue-Morse sequence.
Expand Down
17 changes: 0 additions & 17 deletions axelrod/tests/unit/test_strategy_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
import axelrod as axl
from axelrod._strategy_utils import (
detect_cycle,
inspect_strategy,
recursive_thue_morse,
thue_morse_generator,
)
Expand Down Expand Up @@ -64,22 +63,6 @@ def test_cycle_greater_than_max_size_returns_none(self):
self.assertIsNone(detect_cycle([C, C, D] * 2, min_size=1, max_size=2))


class TestInspectStrategy(unittest.TestCase):
def test_strategies_without_countermeasures_return_their_strategy(self):
tft = axl.TitForTat()
inspector = axl.Alternator()
match = axl.Match((tft, inspector), turns=1)
match.play()
self.assertEqual(tft.history, [C])
self.assertEqual(inspect_strategy(inspector=inspector, opponent=tft), C)

match = axl.Match((tft, inspector), turns=2)
match.play()
self.assertEqual(tft.history, [C, C])
self.assertEqual(inspect_strategy(inspector=inspector, opponent=tft), D)
self.assertEqual(tft.strategy(inspector), D)


class TestRecursiveThueMorse(unittest.TestCase):
def test_initial_values(self):
self.assertEqual(recursive_thue_morse(0), 0)
Expand Down

0 comments on commit 353bf46

Please sign in to comment.