Skip to content

Commit

Permalink
Merge pull request #783 from Axelrod-Python/781
Browse files Browse the repository at this point in the history
Reclassify Random player if p is 0 or 1
  • Loading branch information
drvinceknight committed Dec 4, 2016
2 parents e454a80 + b36f274 commit d620960
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
2 changes: 2 additions & 0 deletions axelrod/strategies/rand.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ def __init__(self, p=0.5):
"""
Player.__init__(self)
self.p = p
if p in [0, 1]:
self.classifier['stochastic'] = False

def strategy(self, opponent):
return random_choice(self.p)
Expand Down
6 changes: 6 additions & 0 deletions axelrod/tests/unit/test_rand.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,3 +28,9 @@ def test_strategy(self):
self.first_play_test(C, random_seed=1)
self.first_play_test(D, random_seed=2)
self.responses_test(response_1, response_2, [C], random_seed=1)

def test_deterministic_classification(self):
"""Test classification when p is 0 or 1"""
for p in [0, 1]:
player = axelrod.Random(p)
self.assertFalse(player.classifier['stochastic'])

0 comments on commit d620960

Please sign in to comment.