diff --git a/axelrod/strategies/rand.py b/axelrod/strategies/rand.py index 0a7593039..077b5a048 100644 --- a/axelrod/strategies/rand.py +++ b/axelrod/strategies/rand.py @@ -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) diff --git a/axelrod/tests/unit/test_rand.py b/axelrod/tests/unit/test_rand.py index 38983bd3e..3b7829f44 100644 --- a/axelrod/tests/unit/test_rand.py +++ b/axelrod/tests/unit/test_rand.py @@ -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'])