本文整理汇总了Python中family.Family.add_kid方法的典型用法代码示例。如果您正苦于以下问题:Python Family.add_kid方法的具体用法?Python Family.add_kid怎么用?Python Family.add_kid使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类family.Family
的用法示例。
在下文中一共展示了Family.add_kid方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
# 需要导入模块: from family import Family [as 别名]
# 或者: from family.Family import add_kid [as 别名]
def __init__(self, num_families, prof_designations=None):
self.goods = 1000
self.food = 1000
self.year = 0
self.peak_villagers = 0
self.peak_families = 0
self.villagers = []
self.prospects = [] # list available mates
self.families = []
# one farmer can feed himself + 1 other person
# so 1 farming family (avg 4 people) generates 240 food
#self.max_outputs = {'farmer': 260, 'crafter': 150, 'guard': 0}
self.max_outputs = {'farmer': 240, 'crafter': 160, 'guard': 0}
# profs
self.prof_list = {
'farmer': [],
'crafter': [],
'guard': [],
}
#self.new_prof_rate = 0.10
self.prof_index = 0
self.baby_rate = 0.2
# houses
self.houses = []
# create empty houses
self.empty_houses = [House() for x in range(num_families*2)]
# professions None when GA is not active
if prof_designations is None:
f = 'farmer'
c = 'crafter'
g = 'guard'
possible_profs = [c, f, g]
self.prof_designations = []
for x in range(1200):
self.prof_designations.append(random.choice(possible_profs))
else:
self.prof_designations = prof_designations
for indx in range(num_families):
# the profs assigned here don't matter
house = self.empty_houses.pop()
new_fam = Family(self, house, None)
new_woman = Villager(self, new_fam, 'f')
new_fam.add_kid(new_woman)
new_woman.force_grow_up() # prof doesn't matter
#new_woman.family.set_profession('farmer')
for indx in range(num_families):
house = self.empty_houses.pop()
new_fam = Family(self, house, None)
new_man = Villager(self, new_fam, 'm')
new_fam.add_kid(new_man)
new_man.force_grow_up()
#new_man.family.set_profession(self.new_profession())
# start with 1 kid each
for family in self.families:
family.check_for_baby(1)
family.update_stats(0)