def random_walk(n): return np.random.rand(11) * n def to_int(x): # gives players at each end equal probability to be picked # 0.5 - 1.5 -> 1 # 0.0 - 0.5 -> 0 (half the probability) return (x - 0.5).astype(int) def objective(x): x_int = to_int(x) points11 = POINTS[x_int] return -(points11.sum() + points11.max()) np.random.seed(0) TRIALS = 10000 lineup = [] total_points = [] constraint_test = [] for i in range(TRIALS): x = random_walk(N) lineup.append(x) total_points.append(-objective(x)) constraint_test.append(constraint_all(x))