热线电话:13121318867

登录
2019-04-09 阅读量: 619
python实现康威的生命游戏(2)
  1. 如果单元格为ON且少于两个ON的邻居,则它将关闭
  2. 如果一个单元是ON并且有两个或三个ON的邻居,它将保持为ON。
  3. 如果单元格为ON并且有三个以上的邻居处于ON状态,则它将关闭。
  4. 如果一个单元格处于OFF状态并且正好有三个相邻的ON,则它将变为ON。

因为我们知道它是如何工作的,接下来我们需要弄清楚如何使其工作。

途径:

1. Initialize the cells in the grid.
2. At each time step in the simulation, for each
cell (i, j) in the grid, do the following:
a. Update the value of cell (i, j) based on
its neighbors, taking into account the
boundary conditions.
b. Update the display of grid values.
28.8667
3
关注作者
收藏
评论(0)

发表评论

暂无数据
推荐帖子