Skip to content

Commit 3b10757

Browse files
committed
Undo or remove various commented lines
1 parent 1658a0c commit 3b10757

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
@@ -179,9 +179,9 @@ def play(self):
179179
if self.reset:
180180
p.reset()
181181
p.set_match_attributes(**self.match_attributes)
182-
# if p.classifier["stochastic"]:
183182
# Generate a random seed for the player
184183
# TODO: Seeds only for stochastic players
184+
# if p.classifier["stochastic"]:
185185
p.set_seed(self._random.random_seed_int())
186186
result = []
187187
for _ in range(turns):

axelrod/player.py

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -71,18 +71,6 @@ def __new__(cls, *args, **kwargs):
7171
"""Caches arguments for Player cloning."""
7272
obj = super().__new__(cls)
7373
obj.init_kwargs = cls.init_params(*args, **kwargs)
74-
# # Set up random seed from the module level random seed
75-
# # in case the user doesn't specific one later.
76-
# need_seed = False
77-
# try:
78-
# seed = kwargs["seed"]
79-
# if seed is None:
80-
# need_seed = True
81-
# except KeyError:
82-
# need_seed = True
83-
# if need_seed:
84-
# seed = _module_random.randint(0, 2**32-1)
85-
# obj._seed = seed
8674
return obj
8775

8876
@classmethod
@@ -209,10 +197,6 @@ def strategy(self, opponent):
209197
"""This is a placeholder strategy."""
210198
raise NotImplementedError()
211199

212-
# def play(self, opponent, noise=0):
213-
# """This pits two players against each other."""
214-
# return simultaneous_play(self, opponent, noise)
215-
216200
def clone(self):
217201
"""Clones the player without history, reapplying configuration
218202
parameters as necessary."""
@@ -236,7 +220,6 @@ def reset(self):
236220
"""
237221
# This also resets the history.
238222
self.__init__(**self.init_kwargs)
239-
# self.set_seed(self._seed)
240223

241224
def update_history(self, play, coplay):
242225
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(axelrod.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
@@ -497,9 +497,9 @@ class TestContriteTitForTat(TestPlayer):
497497
]
498498

499499
def test_init(self):
500-
ctft = self.player()
501-
self.assertFalse(ctft.contrite, False)
502-
self.assertEqual(ctft._recorded_history, [])
500+
player = self.player()
501+
self.assertFalse(player.contrite, False)
502+
self.assertEqual(player._recorded_history, [])
503503

504504
@given(
505505
strategies=strategy_lists(strategies=deterministic_strategies, max_size=1),
@@ -508,10 +508,10 @@ def test_init(self):
508508
@settings(deadline=None)
509509
def test_is_tit_for_tat_with_no_noise(self, strategies, turns):
510510
tft = axelrod.TitForTat()
511-
ctft = self.player()
511+
player = self.player()
512512
opponent = strategies[0]()
513513
m1 = axelrod.Match((tft, opponent), turns)
514-
m2 = axelrod.Match((ctft, opponent), turns)
514+
m2 = axelrod.Match((player, opponent), turns)
515515
self.assertEqual(m1.play(), m2.play())
516516

517517
def test_strategy_with_noise(self):
@@ -528,26 +528,26 @@ def test_strategy_with_noise(self):
528528
self.assertEqual(player._recorded_history, [C])
529529
self.assertEqual(opponent.history, [C])
530530

531-
# # After noise: is contrite
532-
# ctft.play(opponent)
533-
# self.assertEqual(ctft.history, [D, C])
534-
# self.assertEqual(ctft._recorded_history, [C, C])
535-
# self.assertEqual(opponent.history, [C, D])
536-
# self.assertTrue(ctft.contrite)
537-
#
538-
# # Cooperates and no longer contrite
539-
# ctft.play(opponent)
540-
# self.assertEqual(ctft.history, [D, C, C])
541-
# self.assertEqual(ctft._recorded_history, [C, C, C])
542-
# self.assertEqual(opponent.history, [C, D, D])
543-
# self.assertFalse(ctft.contrite)
544-
#
545-
# # Goes back to playing tft
546-
# ctft.play(opponent)
547-
# self.assertEqual(ctft.history, [D, C, C, D])
548-
# self.assertEqual(ctft._recorded_history, [C, C, C, D])
549-
# self.assertEqual(opponent.history, [C, D, D, D])
550-
# self.assertFalse(ctft.contrite)
531+
# After noise: is contrite
532+
player.play(opponent)
533+
self.assertEqual(player.history, [D, C])
534+
self.assertEqual(player._recorded_history, [C, C])
535+
self.assertEqual(opponent.history, [C, D])
536+
self.assertTrue(player.contrite)
537+
538+
# Cooperates and no longer contrite
539+
player.play(opponent)
540+
self.assertEqual(player.history, [D, C, C])
541+
self.assertEqual(player._recorded_history, [C, C, C])
542+
self.assertEqual(opponent.history, [C, D, D])
543+
self.assertFalse(player.contrite)
544+
545+
# Goes back to playing tft
546+
player.play(opponent)
547+
self.assertEqual(player.history, [D, C, C, D])
548+
self.assertEqual(player._recorded_history, [C, C, C, D])
549+
self.assertEqual(opponent.history, [C, D, D, D])
550+
self.assertFalse(player.contrite)
551551

552552

553553
class TestAdaptiveTitForTat(TestPlayer):

0 commit comments

Comments
 (0)