Skip to content

Commit 06255f3

Browse files
committed
Undo or remove various commented lines
1 parent 59f156d commit 06255f3

File tree

6 files changed

+29
-65
lines changed

6 files changed

+29
-65
lines changed

axelrod/evolvable_player.py

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -36,24 +36,6 @@ def create_new(self, **kwargs):
3636
init_kwargs.update(kwargs)
3737
return self.__class__(**init_kwargs)
3838

39-
# def clone(self):
40-
# """Clones the player without history, reapplying configuration
41-
# parameters as necessary.
42-
#
43-
# We're overriding Player.clone to also propagate the seed because EvolvablePlayers
44-
# currently randomize themselves on initialization.
45-
# """
46-
#
47-
# # You may be tempted to re-implement using the `copy` module
48-
# # Note that this would require a deepcopy in some cases and there may
49-
# # be significant changes required throughout the library.
50-
# # Consider overriding in special cases only if necessary
51-
# cls = self.__class__
52-
# new_player = cls(**self.init_kwargs, seed=self._seed)
53-
# new_player.match_attributes = copy.copy(self.match_attributes)
54-
# # new_player.set_seed(self._seed)
55-
# return new_player
56-
5739
# Serialization and deserialization. You may overwrite to obtain more human readable serializations
5840
# but you must overwrite both.
5941

axelrod/match.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -178,9 +178,9 @@ def play(self):
178178
if self.reset:
179179
p.reset()
180180
p.set_match_attributes(**self.match_attributes)
181-
# if p.classifier["stochastic"]:
182181
# Generate a random seed for the player
183182
# TODO: Seeds only for stochastic players
183+
# if p.classifier["stochastic"]:
184184
p.set_seed(self._random.random_seed_int())
185185
result = []
186186
for _ in range(turns):

axelrod/player.py

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -28,18 +28,6 @@ def __new__(cls, *args, **kwargs):
2828
"""Caches arguments for Player cloning."""
2929
obj = super().__new__(cls)
3030
obj.init_kwargs = cls.init_params(*args, **kwargs)
31-
# # Set up random seed from the module level random seed
32-
# # in case the user doesn't specific one later.
33-
# need_seed = False
34-
# try:
35-
# seed = kwargs["seed"]
36-
# if seed is None:
37-
# need_seed = True
38-
# except KeyError:
39-
# need_seed = True
40-
# if need_seed:
41-
# seed = _module_random.randint(0, 2**32-1)
42-
# obj._seed = seed
4331
return obj
4432

4533
@classmethod
@@ -163,10 +151,6 @@ def strategy(self, opponent):
163151
"""This is a placeholder strategy."""
164152
raise NotImplementedError()
165153

166-
# def play(self, opponent, noise=0):
167-
# """This pits two players against each other."""
168-
# return simultaneous_play(self, opponent, noise)
169-
170154
def clone(self):
171155
"""Clones the player without history, reapplying configuration
172156
parameters as necessary."""
@@ -190,7 +174,6 @@ def reset(self):
190174
"""
191175
# This also resets the history.
192176
self.__init__(**self.init_kwargs)
193-
# self.set_seed(self._seed)
194177

195178
def update_history(self, play, coplay):
196179
self.history.append(play, coplay)

axelrod/random_.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ class RandomGenerator(object):
1111
Enables reproducibility of player behavior, matches,
1212
and tournaments."""
1313
def __init__(self, seed=None):
14-
# self.random = random.Random()
1514
# _random is the internal object that generators random values
1615
self._random = RandomState()
1716
self.original_seed = seed

axelrod/tests/strategies/test_geller.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -66,9 +66,9 @@ def test_returns_foil_inspection_strategy_of_opponent(self):
6666

6767
self.versus_test(axl.Darwin(), expected_actions=[(C, C), (C, C), (C, C)], seed=3)
6868

69-
# self.versus_test(
70-
# axelrod.MindReader(), expected_actions=[(D, D), (D, D), (D, D)], seed=1
71-
# )
69+
self.versus_test(
70+
axelrod.MindReader(), expected_actions=[(D, D), (D, D), (D, D)], seed=1
71+
)
7272

7373

7474
class TestGellerCooperator(TestGeller):

axelrod/tests/strategies/test_titfortat.py

Lines changed: 25 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -708,9 +708,9 @@ class TestContriteTitForTat(TestPlayer):
708708
]
709709

710710
def test_init(self):
711-
ctft = self.player()
712-
self.assertFalse(ctft.contrite, False)
713-
self.assertEqual(ctft._recorded_history, [])
711+
player = self.player()
712+
self.assertFalse(player.contrite, False)
713+
self.assertEqual(player._recorded_history, [])
714714

715715
@given(
716716
strategies=strategy_lists(strategies=deterministic_strategies, max_size=1),
@@ -719,10 +719,10 @@ def test_init(self):
719719
@settings(deadline=None)
720720
def test_is_tit_for_tat_with_no_noise(self, strategies, turns):
721721
tft = axl.TitForTat()
722-
ctft = self.player()
722+
player = self.player()
723723
opponent = strategies[0]()
724724
m1 = axl.Match((tft, opponent), turns)
725-
m2 = axl.Match((ctft, opponent), turns)
725+
m2 = axl.Match((player, opponent), turns)
726726
self.assertEqual(m1.play(), m2.play())
727727

728728
def test_strategy_with_noise(self):
@@ -739,26 +739,26 @@ def test_strategy_with_noise(self):
739739
self.assertEqual(player._recorded_history, [C])
740740
self.assertEqual(opponent.history, [C])
741741

742-
# # After noise: is contrite
743-
# ctft.play(opponent)
744-
# self.assertEqual(ctft.history, [D, C])
745-
# self.assertEqual(ctft._recorded_history, [C, C])
746-
# self.assertEqual(opponent.history, [C, D])
747-
# self.assertTrue(ctft.contrite)
748-
#
749-
# # Cooperates and no longer contrite
750-
# ctft.play(opponent)
751-
# self.assertEqual(ctft.history, [D, C, C])
752-
# self.assertEqual(ctft._recorded_history, [C, C, C])
753-
# self.assertEqual(opponent.history, [C, D, D])
754-
# self.assertFalse(ctft.contrite)
755-
#
756-
# # Goes back to playing tft
757-
# ctft.play(opponent)
758-
# self.assertEqual(ctft.history, [D, C, C, D])
759-
# self.assertEqual(ctft._recorded_history, [C, C, C, D])
760-
# self.assertEqual(opponent.history, [C, D, D, D])
761-
# self.assertFalse(ctft.contrite)
742+
# After noise: is contrite
743+
player.play(opponent)
744+
self.assertEqual(player.history, [D, C])
745+
self.assertEqual(player._recorded_history, [C, C])
746+
self.assertEqual(opponent.history, [C, D])
747+
self.assertTrue(player.contrite)
748+
749+
# Cooperates and no longer contrite
750+
player.play(opponent)
751+
self.assertEqual(player.history, [D, C, C])
752+
self.assertEqual(player._recorded_history, [C, C, C])
753+
self.assertEqual(opponent.history, [C, D, D])
754+
self.assertFalse(player.contrite)
755+
756+
# Goes back to playing tft
757+
player.play(opponent)
758+
self.assertEqual(player.history, [D, C, C, D])
759+
self.assertEqual(player._recorded_history, [C, C, C, D])
760+
self.assertEqual(opponent.history, [C, D, D, D])
761+
self.assertFalse(player.contrite)
762762

763763

764764
class TestAdaptiveTitForTat(TestPlayer):

0 commit comments

Comments
 (0)