def __init__(self, rps, mutation_tendency = 0.3, potency = 0.5): Organism.__init__(self, mutation_tendency, potency) # calculate the new tuple indicating the chromosone's RPS strategy rps_tuple = tuple([self.post_mutation_value(mutation_tendency, i) for i in rps]) self.rps = normalize_tuple(rps_tuple)
def create_random_rps_tuple(self): """Generate a random RPS probability distribution. Returns a normalized tuple.""" num_actions = len(self.actions) return utility.normalize_tuple( tuple([random() for j in range(num_actions)]))