14.13. Self Check¶
You have attempted of activities on this page
Q-1: is the tendency of many animals to help other animals, even to their own detriment. This creates a conflict with , where it suggests that animals live in a state of constant competition.
Q-2: Please complete the play function.def play(self, agent1, agent2): --- agent1.reset() --- agent2.reset() --- for i in range(self.num_rounds): --- resp1 = agent1.respond(agent2) --- resp2 = agent2.respond(agent1) --- pay1, pay2 = self.payoffs[resp1, resp2] --- agent1.append(resp1, pay1) --- agent2.append(resp2, pay2) --- return agent1.score, agent2.score
Q-3: Please put the step function in order.def step(self): n = len(self.agents) fits = self.get_fitnesses() --- # see who dies index_dead = self.choose_dead(fits) num_dead = len(index_dead) --- # replace the dead with copies of the living replacements = self.choose_replacements(num_dead, fits) self.agents[index_dead] = replacements --- # update any instruments self.update_instruments()