genome.py 文件源码

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

项目:PyNEAT 作者: hugofragata 项目源码 文件源码
def mutation(self, mutation_type):
        if mutation_type not in MUTATION_TYPES:
            raise GenomeError("mutation type not supported")
        threshold = random.uniform(self.mutation_lower_threshold, self.mutation_higher_threshold)
        if threshold < self.mutation_threshold:
            return
        if mutation_type == "add_node":
            self.mutate_add_node()
        elif mutation_type == "remove_node":
            self.mutate_remove_node()
        elif mutation_type == "add_connection":
            self.mutate_add_connection()
        elif mutation_type == "remove_connection":
            self.mutate_remove_connection()
        else:
            raise GenomeError("something wrong happened in mutation.")
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号