File tree Expand file tree Collapse file tree 3 files changed +7
-10
lines changed Expand file tree Collapse file tree 3 files changed +7
-10
lines changed Original file line number Diff line number Diff line change @@ -110,8 +110,11 @@ def __init__(
110
110
given
111
111
fitness_transformation:
112
112
A function mapping a score to a (non-negative) float
113
+ mutation_method:
114
+ A string indicating if the mutation method should be between original types ("transition")
115
+ or based on the player's mutation method, if present ("atomic").
113
116
stop_on_fixation:
114
- A bool indicating if the process should stop on fixation.
117
+ A bool indicating if the process should stop on fixation
115
118
"""
116
119
self .turns = turns
117
120
self .prob_end = prob_end
Original file line number Diff line number Diff line change @@ -73,14 +73,8 @@ def randrange(a: int, b: int) -> int:
73
73
74
74
def random_vector (size ):
75
75
"""Create a random vector of values in [0, 1] that sums to 1."""
76
- vector = []
77
- s = 1
78
- for _ in range (size - 1 ):
79
- r = s * random .random ()
80
- vector .append (r )
81
- s -= r
82
- vector .append (s )
83
- return vector
76
+ vector = np .random .random (size )
77
+ return vector / np .sum (vector )
84
78
85
79
86
80
class Pdf (object ):
Original file line number Diff line number Diff line change @@ -232,7 +232,7 @@ def test_vector_to_instance(self):
232
232
num_states = 4
233
233
vector = []
234
234
for _ in range (2 * num_states ):
235
- vector += random_vector (num_states )
235
+ vector . extend ( list ( random_vector (num_states )) )
236
236
for _ in range (num_states + 1 ):
237
237
vector .append (random .random ())
238
238
player = self .player_class (num_states = num_states )
You can’t perform that action at this time.
0 commit comments