初始化函数

def init(self, cross_rate, mutation_rate, n_population, n_iterations, password): self.cross_rate = cross_rate # 交叉概率 self.mutate_rate = mutation_rate # 变异概率 self.n_population = n_population # 种群数量 self.n_iterations = n_iterations # 迭代次数 self.password = password # 要破解的密码 self.password_size = len(self.password) # 要破解密码的长度 self.password_ascii = np.fromstring(self.password, dtype=np.uint8) # 将password转换成ASCII码 self.ascii_bounder = [32, 126+1] # ASCII码边界,用于生成随机种群

def __init__self cross_rate mutation_rate n_population n_iterations password selfcross_rate = cross_rate selfmutate_rate = mutation_rate selfn_population = n_population sel

原文地址: https://www.cveoy.top/t/topic/b34P 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录