person.py 文件源码

python
阅读 29 收藏 0 点赞 0 评论 0

项目:talktown 作者: james-owen-ryan 项目源码 文件源码
def _init_retcon_marriage(self, spouse):
        """Jump back in time to instantiate a marriage that began outside the town."""
        config = self.sim.config
        # Change actual sim year to marriage year, instantiate a Marriage object
        marriage_date = self.birth_year + (
            random.normalvariate(
                config.person_ex_nihilo_age_at_marriage_mean, config.person_ex_nihilo_age_at_marriage_sd
            )
        )
        if (
            # Make sure spouses aren't too young for marriage and that marriage isn't slated
            # to happen after the town has been founded
            marriage_date - self.birth_year < config.person_ex_nihilo_age_at_marriage_floor or
            marriage_date - spouse.birth_year < config.person_ex_nihilo_age_at_marriage_floor or
            marriage_date >= self.sim.true_year
        ):
            # If so, don't bother regenerating -- just set marriage year to last year and move on
            marriage_date = self.sim.true_year - 1
        self.sim.year = int(round(marriage_date))
        self.marry(spouse)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号