Life_1

Movie: 猫鼠游戏

Key words: Frank, check

Learn: Design

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
def paint_cell():R, XY = 8, [50 + i * 20 for i in range(36)]if life_Cell.work:for i, x in enumerate(XY):for j, y in enumerate(XY):if life_Cell.items[i + 1][j + 1]:tv.itemconfig(square[i][j], fill='black', outline='red') else:tv.itemconfig(square[i][j], fill='white', outline='white')tv.update()life_Cell.evolution()if life_Cell.constant():life_Cell.work = Falseif sum(sum(life_Cell.items, [])):py.mixer.music.stop()msg.showinfo('警告!', '模拟演化完成,生命细胞达到稳定状态!') else:py.mixer.music.stop()msg.showinfo('警告!', '模拟演化完成,生命细胞达到灭亡状态!')world.after(speed, paint_cell)def click_Start():if sum(sum(life_Cell.items, [])):life_Cell.old = [] life_Cell.work = Truepy.mixer.init()py.mixer.music.load(r'E:\毕业设计\生命游戏细胞自动机\music.wav')py.mixer.music.play(-1) else:msg.showinfo('警告!', '初始生命细胞不能为空,请任意单击在方格内放置生命细胞,或者单击随机生成按钮!')def click_Pause():py.mixer.music.stop()life_Cell.work = not life_Cell.workif life_Cell.work:life_Cell.old.clear()life_Cell.current()global speedspeed = 200label1 = tk.Label(world, text='恢复速度:200,系统加载完毕', width=32, background='yellow')label1.place(x=780, y=475)def click_cell(event): x, y = (event.x - 40) // 20, (event.y - 40) // 20 if not life_Cell.work: if life_Cell.items[x + 1][y + 1]: tv.itemconfig(square[x][y], fill='white', outline='blue') else: tv.itemconfig(square[x][y], fill='red', outline='blue') life_Cell.items[x + 1][y + 1] = not life_Cell.items[x + 1][y + 1]解释代码
05-17
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值