Skip to content

Commit d620960

Browse files
Merge pull request #783 from Axelrod-Python/781
Reclassify Random player if p is 0 or 1
2 parents e454a80 + b36f274 commit d620960

File tree

2 files changed

+8
-0
lines changed

2 files changed

+8
-0
lines changed

axelrod/strategies/rand.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,8 @@ def __init__(self, p=0.5):
3636
"""
3737
Player.__init__(self)
3838
self.p = p
39+
if p in [0, 1]:
40+
self.classifier['stochastic'] = False
3941

4042
def strategy(self, opponent):
4143
return random_choice(self.p)

axelrod/tests/unit/test_rand.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,3 +28,9 @@ def test_strategy(self):
2828
self.first_play_test(C, random_seed=1)
2929
self.first_play_test(D, random_seed=2)
3030
self.responses_test(response_1, response_2, [C], random_seed=1)
31+
32+
def test_deterministic_classification(self):
33+
"""Test classification when p is 0 or 1"""
34+
for p in [0, 1]:
35+
player = axelrod.Random(p)
36+
self.assertFalse(player.classifier['stochastic'])

0 commit comments

Comments
 (0)