def chance_to_have_child(self, year=None, return_boolean=True): chance = 0.0 if year: age = self.age_at_year(year) else: age = self.age if age > self.world_obj.age_of_consent: # Up to 20% chance based on age max_age = self.world_obj.age_of_consent + (40 if self.gender is 'Male' else 30) chance += 0.2 - math_helpers.percent_range(value=age, start_min=self.world_obj.age_of_consent, start_max=max_age, end_min=0, end_max=0.2) # Up to 10% chance of having kids if lower educated chance += 0.1 - math_helpers.percent_range(self.education, 0, 100, 0, .1) # Reduce 10% chance if high conflict chance -= math_helpers.percent_range(self.conflict, 0, 100, 0, .1) #Up to 15% higher if wealthy chance += math_helpers.percent_range(self.economic, 0, 100, 0, .15) # 5% less chance per kid chance -= (self.num_kids * .05) chance += float(self.get('passion', 0)) * 0.01 chance = math_helpers.clamp(chance, 0.01, 0.4) if return_boolean: chance = chance > numpy.random.random() return chance
def age_of_consent(self): # Being "of age" changes through the years, from 14 to 20 # TODO: Modify this by racial longevity return int(math_helpers.percent_range(value=self.year, start_min=1000, start_max=2000, end_min=14, end_max=20))