def get_rps_choice(self, rps_distribution): """Return a random choice given a probability distribution between the available actions.""" # This has been left in simply because it hardly needs to be changed. Modify # the variable names to fit your game. random_choice = random() index_choice = utility.get_distribution_choice(rps_distribution) return self.actions[index_choice]
def get_rps_choice(self, rps_distribution): """Return a random choice given a probability distribution between the available actions.""" # This has been left in simply because it hardly needs to be changed. Modify # the variable names to fit your game. random_choice = random() index_choice = utility.get_distribution_choice(rps_distribution) return self.actions[index_choice]
chromosones = game.generate_initial_population() # used for debugging. And watching organism changes over generations. """for chrom in chromosones: print chrom print chrom.rps """ organisms = [] user_rps = (1, 0, 0) #user_rps = utility.normalize_tuple((0.2, 0.5, 0.3)) print "User distribution:", user_rps # Loop through each game turn. Select a random user choice out of the provided # distribution each time. for i in range(NUM_GAME_TURNS): user_index_selection = utility.get_distribution_choice(user_rps) user_action = game.actions[user_index_selection] organisms = game.run_game_turn(chromosones, user_action) #print get_organism_stats(organisms) organism_list = [] for chrom in organisms: organism_list.append([ chrom.hit_points, [round(rps_element, 2) for rps_element in chrom.rps] ]) organism_list = sorted(organism_list) print "Top 5 (or less) organisms, sorted by hit points:" for org in reversed(organism_list[-5:]): print org
chromosones = game.generate_initial_population() # used for debugging. And watching organism changes over generations. """for chrom in chromosones: print chrom print chrom.rps """ organisms = [] user_rps = (1, 0, 0) #user_rps = utility.normalize_tuple((0.2, 0.5, 0.3)) print "User distribution:", user_rps # Loop through each game turn. Select a random user choice out of the provided # distribution each time. for i in range(NUM_GAME_TURNS): user_index_selection = utility.get_distribution_choice(user_rps) user_action = game.actions[user_index_selection] organisms = game.run_game_turn(chromosones, user_action) #print get_organism_stats(organisms) organism_list = [] for chrom in organisms: organism_list.append([chrom.hit_points, [round(rps_element, 2) for rps_element in chrom.rps]]) organism_list = sorted(organism_list) print "Top 5 (or less) organisms, sorted by hit points:" for org in reversed(organism_list[-5:]): print org strongest_organisms = game.get_strongest_organisms(organisms)
def get_rps_choice(self, rps_distribution): """Return a random choice given a probability distribution between R, P, and S.""" random_choice = random() index_choice = utility.get_distribution_choice(rps_distribution) return self.actions[index_choice]
def get_rps_choice(self, rps_distribution): """Return a random choice given a probability distribution between R, P, and S.""" random_choice = random() index_choice = utility.get_distribution_choice(rps_distribution) return self.actions[index_choice]