def new_ending_condition(mas): """ Fonction permettant d'arréter la simulation sous deux conditions: - le nombre de cycl est égal au nombre de cycle maximal - si plus aucun agent vivant ne subsiste """ alive_agents = p.size(get_pop(mas)) return (get_cycle(mas) >= get_max_cycle(mas) or alive_agents == 0)
def make_a_child(agent): """ règle permettant la reproduction asexuée selon une certaine probablité les agents doivent être dans un intervalle d'âge précis """ pop = get_population(agent) env = get_env(agent) min_age = p.get_pop_property(pop, "MIN_AGE_TO_MAKE_CHILDS") max_age = p.get_pop_property(pop, "MAX_AGE_TO_MAKE_CHILDS") max_pop = p.get_pop_property(pop, "MAX_POP") min_prob, max_prob = p.get_pop_property(pop, "PROB_TO_HAVE_SEX") if (min_age <= get_age(agent) <= max_age and theres_is_an_other_sex_around(agent) \ and randint(min_prob,max_prob) == 1 and p.size(pop) < max_pop ): new_child = new_instance(pop) set_age(new_child, 0) set_sugar_level(agent, 0) #le nouveau-née hérite du métabolisme et de la vision de capacité de son géniteur set_metabolism(new_child, get_metabolism(agent)) set_vision_capacity(new_child, get_vision_capacity(agent)) agents_list = p.get_agents(pop) agents_list.append(new_child)
def make_a_child(agent): """ règle permettant la reproduction asexuée selon une certaine probablité les agents doivent être dans un intervalle d'âge précis """ pop = get_population(agent) env = get_env(agent) min_age = p.get_pop_property(pop,"MIN_AGE_TO_MAKE_CHILDS") max_age = p.get_pop_property(pop,"MAX_AGE_TO_MAKE_CHILDS") max_pop = p.get_pop_property(pop,"MAX_POP") min_prob,max_prob = p.get_pop_property(pop,"PROB_TO_HAVE_SEX") if (min_age <= get_age(agent) <= max_age and theres_is_an_other_sex_around(agent) \ and randint(min_prob,max_prob) == 1 and p.size(pop) < max_pop ): new_child = new_instance(pop) set_age(new_child,0) set_sugar_level(agent,0) #le nouveau-née hérite du métabolisme et de la vision de capacité de son géniteur set_metabolism(new_child,get_metabolism(agent)) set_vision_capacity(new_child,get_vision_capacity(agent)) agents_list = p.get_agents(pop) agents_list.append(new_child)