def iterate_being(self, being): """ Fonction qui itère un individu de l'état n à l'état n+1. """ being.age += 1 if being.age >= being.life_duration: self.stats["died_of_old_age"][being.type_id] += 1 self.delete_being(being) return if being.reproduction_current_cooldown > 0: being.reproduction_current_cooldown -= 1 if being.is_plant(): being.satiation += max( 1 / self.plant_count_map[being.get_int_position()] - 0.3, 0) else: being.satiation -= 1 if self.decease_iteration(being): return if (being.satiation <= 0): self.stats["died_of_hunger"][being.type_id] += 1 self.delete_being(being) return if (being.satiation < being.hunger_threshold and not being.is_plant()): if self.find_and_eat(being): return else: if self.move_towards_prey(being): return if (being.satiation > being.reproduction_threshold and being.reproduction_current_cooldown <= 0): self.reproduction(being) if not being.is_plant(): self.move_being(being)
def iterate_being(self, being): if being.reproduction_current_cooldown > 0: being.reproduction_current_cooldown -= 1 if being.is_plant(): being.satiation += max( 1 / self.plant_count_map[being.get_int_position()] - 0.3, 0) else: being.satiation -= 1 if (being.satiation <= 0): self.delete_being(being) return if (being.satiation < being.hunger_threshold and not being.is_plant()): if self.find_and_eat(being): return else: if self.move_towards_prey(being): return if (being.satiation > being.reproduction_threshold and being.reproduction_current_cooldown <= 0): self.reproduction(being) if not being.is_plant(): self.move_being(being)
def add_being_to_map(self, being): self.beings_map[being.get_int_position()].add( being.get_position_in_list()) if being.is_plant(): self.plant_count_map[being.get_int_position()] += 1
def remove_being_from_map(self, being): self.beings_map[being.get_int_position()].remove( being.get_position_in_list()) if being.is_plant(): self.plant_count_map[being.get_int_position()] -= 1