小编Ato*_*nut的帖子

我一直在用Python制作康威的生命游戏,为什么它不起作用?

因此,在 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)

python pygame conways-game-of-life

1
推荐指数
1
解决办法
386
查看次数

标签 统计

conways-game-of-life ×1

pygame ×1

python ×1