Ejemplo n.º 1
0
 def _get_men_availability_factor(young_men, young_women):
     if young_women > 0:
         men_factor = young_men / young_women
         res = (men_factor * 0.5) / 2
         return Utils.saturate(Utils.saturate(res, 1.0), men_factor * 3)
     else:
         return 0
Ejemplo n.º 2
0
 def _update_old(self, prosp):
     mortality_men = Utils.saturate(self._mortality["old-men"] * Utils.opposite(prosp), 1.0)
     mortality_women = Utils.saturate(self._mortality["old-women"] * Utils.opposite(prosp), 1.0)
     n_old_men = self._old_men
     n_old_women = self._old_women
     [m_dead, m_alive] = Utils.rsplit(n_old_men, mortality_men)
     [w_dead, w_alive] = Utils.rsplit(n_old_women, mortality_women)
     # print("Dead old men: " + str(m_dead) + " dead old women: " + str(w_dead))
     return [0, 0, 0, -m_dead, -w_dead]
Ejemplo n.º 3
0
def chance_to_discover_agriculture(group, world):
    if group.nomadism != "nomadic" and not ("Agriculture" in group.activities):
        agr_prosp = group.get_base_prosperity_per_activity("Agriculture", world, group.position)
        p = (agr_prosp - 0.75) * 6.0
        p *= discovery_population_factor(group.total_persons, 200)
        return Utils.saturate(max(0.0, p), 0.3)
    else:
        return 0
Ejemplo n.º 4
0
def chance_to_become_sedentary(group):
    if group.nomadism == "semi-sedentary" and "Agriculture" in group.activities:
        prosperity = group.prosperity
        if prosperity > 0.72:
            return Utils.saturate((prosperity - 0.75) / 1.5, 0.2)
        else:
            return 0
    else:
        return 0
Ejemplo n.º 5
0
 def get_prosperity_per_activity(self, world, position):
     """
     This function returns the prosperity of each activity of group in the given position.
     :param world: The world in which the group lives.
     :param position: The position to check.
     :return: A list with the prosperity for each activity of the group.
     """
     prosperity = []
     for activity in self.activities:
         base = self.get_base_prosperity_per_activity(activity, world, position)
         crowding = self._get_crowding_per_activity(activity)
         prosperity.append(Utils.saturate(base * crowding, 1.0))
     return prosperity
Ejemplo n.º 6
0
def chance_to_develop_trade(group, occupied_positions):
    if group.nomadism == "sedentary" and not group.knows_trade:
        neighbours = groups_around(group.position, group.trade_radius, occupied_positions)
        if neighbours > 0:
            prosperity = group.prosperity
            if prosperity > 0.8:
                return Utils.saturate((prosperity - 0.78) / 1.3, 0.3)
            else:
                return 0.05
        else:
            return 0
    else:
        return 0
Ejemplo n.º 7
0
def chance_to_become_semi_sedentary(group):
    prosperity = group.prosperity
    if group.nomadism == "nomadic" and prosperity > 0.6:
        return Utils.saturate((prosperity - 0.75) / 1.5, 0.1)
    else:
        return 0
Ejemplo n.º 8
0
def chance_to_trade(group, information):
    if group.knows_trade:
        neighbours = groups_around_info(group.position, group.trade_radius, information["groups"])
        chance = Utils.saturate(len(neighbours) / (group.trade_radius * group.trade_radius - 1), 0.8)
        return [chance, neighbours]
    return [0, 0]