def have_child(self, child_data={}, spouse=None, event_id=0): father = self if self.gender is 'Male' else spouse mother = spouse if self.gender is 'Male' else self if not isinstance(father, Person): father = Person(self.world_obj, father, 'Male', 'Father') spouse = father if not isinstance(mother, Person): mother = Person(self.world_obj, mother, 'Female', 'Mother') spouse = mother child_dna, temp = dna_helpers.combine_dna(mother=mother.dna, father=father.dna) child_gender = dna_helpers.gender_from_dna(child_dna) child_dna = math_helpers.get_val(child_data, 'dna', child_dna) child_data_new = { "dna": child_dna, "gender": child_gender, "father_name": father.name, "mother_name": mother.name } child_data = math_helpers.extend(child_data, child_data_new) child = Person(self.world_obj, child_data, gender=child_gender, role='Child') child.create_name() world_data = self.world_obj.world_data birth_place = create_random_item(world_data=world_data, set_random_key=False, pattern='birthplace') birth_event_data = apply_event_effects(person_data=child.pointer, world_data=world_data, age=0, event_data=birth_place, event_type='birthplace', event_id=event_id, tag_manager=self.world_obj.tag_manager) child.set('birth_year', int(self.world_obj.get('year'))) child.set('birth_event', birth_event_data) if spouse is None: child.set('parents_unmarried_while_born', True) child.set('family_name', mother.family_name) self.conflict += 2 spouse.conflict += 2 self.economic -= 2 spouse.economic -= 2 else: child.set('family_name', self.family_name if self.gender is 'Male' else mother.family_name) self.conflict -= 1 self.economic -= 1 spouse.economic -= 1 self.education += 1 child.create_name(set_to_person=True) self.world_obj.add_person(child) self.attribute_mod_update('Happiness', numpy.random.randint(-2, 2)) self.attribute_mod_update('Constitution', numpy.random.randint(-2, 0)) self.attribute_mod_update('Passion', numpy.random.randint(-4, -1)) if self.gender is 'Female': self.attribute_mod_update('Happiness', -1) self.attribute_mod_update('Constitution', -1) return child
def generate_dna(self, force_generation_if_exists=False): if force_generation_if_exists or self.dna is '' or self.dna and len(self.dna) < 3: self.dna, temp = dna_helpers.combine_dna(self.mother.dna, self.father.dna, self.rand_seed_counter) self.dna = dna_helpers.set_dna_gender(self.dna, self.gender)