当前位置: 首页>>代码示例>>Python>>正文


Python Family.add_kid方法代码示例

本文整理汇总了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)
开发者ID:ctasims,项目名称:village-people,代码行数:66,代码来源:village.py


注:本文中的family.Family.add_kid方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。