We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 62f6934 commit 13969ddCopy full SHA for 13969dd
axelrod/random_.py
@@ -2,9 +2,6 @@
2
import numpy
3
from axelrod import Actions
4
5
-# A dictionary mapping 0 or 1 probability of cooperating to an action.
6
-choices = {0: Actions.D, 1: Actions.C}
7
-
8
9
def random_choice(p=0.5):
10
"""
@@ -23,11 +20,16 @@ def random_choice(p=0.5):
23
20
-------
24
21
axelrod.Actions.C or axelrod.Actions.D
25
22
26
- try:
27
- return choices[p]
28
- except KeyError:
29
- r = random.random()
30
- return choices[r < p]
+ if p == 0:
+ return Actions.D
+
+ if p == 1:
+ return Actions.C
+ r = random.random()
+ if r < p:
31
32
33
34
35
def randrange(a, b):
0 commit comments