因此,在 Cell.update() 中检测它是否应该存活的代码一定有问题,但是我硬编码的滑翔机没有按预期工作。第一代和第二代按预期工作,但到了第三代就消失了。有人知道问题是什么吗?我知道代码有点乱,但我对 python 很陌生,所以这是预料之中的。提前致谢!
这是代码:
import pygame
"""
rules:
1. Any live cell with two or three live neighbours survives.
2. Any dead cell with three live neighbours becomes a live cell.
3. All other live cells die in the next generation. Similarly, all other dead cells stay dead.
number cells on screen = 32x18
cell size = 30x30
"""
# variables
WIDTH = 960
HEIGHT = 540
TITLE = "Conway's Game Of Life"
GRID_COLOUR = (200, 200, 200) …Run Code Online (Sandbox Code Playgroud)