编码操练招式——康威生命游戏
来源:互联网 发布:考勤软件叫什么 编辑:程序博客网 时间:2024/05/17 01:37
康威生命游戏(Conway’s Game Of Life)
在一个有边界的二维网格(Grid)中,每个格子中生活着一个细胞(Cell);每个细胞只有两种生命状态:生(Alive)或死(Dead);网格矩阵边界之外没有细胞;
每天天一亮,所有格子里的细胞都统一通过下面4个规则,进化到下一代。每个细胞下一代的生命状态与自己和8个邻居进化前的生命状态有关:
1)对于活的细胞,若其活着的邻居过于稀少,以至于少于2个,那么它的下一代就死去了;
2)对于活的细胞,若其活着的邻居过于稠密,以至于多于3个,那么它的下一代也会死去;
3)对于活的细胞,若其活着的邻居恰好是2~3个,那么它的下一代会接着愉快地活着;
4)对于死的细胞,若其活着的邻居恰好是3个,那么它的下一代会复生。
2. Any live cell with more than three live neighbours dies, as if by overcrowding.
3. Any live cell with two or three live neighbours lives on to the next generation.
4. Any dead cell with exactly three live neighbours becomes a live cell.
Examples: * indicates live cell, . indicates dead cell
Example input: (4 x 8 grid)
4 8
........
....*...
...**...
........
Example output:
4 8
........
...**...
...**...
........
在一个有边界的二维网格(Grid)中,每个格子中生活着一个细胞(Cell);每个细胞只有两种生命状态:生(Alive)或死(Dead);网格矩阵边界之外没有细胞;
每天天一亮,所有格子里的细胞都统一通过下面4个规则,进化到下一代。每个细胞下一代的生命状态与自己和8个邻居进化前的生命状态有关:
1)对于活的细胞,若其活着的邻居过于稀少,以至于少于2个,那么它的下一代就死去了;
2)对于活的细胞,若其活着的邻居过于稠密,以至于多于3个,那么它的下一代也会死去;
3)对于活的细胞,若其活着的邻居恰好是2~3个,那么它的下一代会接着愉快地活着;
4)对于死的细胞,若其活着的邻居恰好是3个,那么它的下一代会复生。
Your task is to write a program to calculate the next generation of Conway's game of life, given any starting position. You start with a two dimensional grid of cells, where each cell is either alive or dead. The grid is finite, and no life can exist off the edges. When calculating the next generation of the grid, follow these four rules:
1. Any live cell with fewer than two live neighbours dies, as if caused by underpopulation.2. Any live cell with more than three live neighbours dies, as if by overcrowding.
3. Any live cell with two or three live neighbours lives on to the next generation.
4. Any dead cell with exactly three live neighbours becomes a live cell.
Examples: * indicates live cell, . indicates dead cell
Example input: (4 x 8 grid)
4 8
........
....*...
...**...
........
Example output:
4 8
........
...**...
...**...
........
(英文资料来源:http://www.cyber-dojo.com/setup/show)
- 编码操练招式——康威生命游戏
- 编码操练招式——网球计分
- 练手:康威生命游戏demo
- 康威生命游戏的学习
- python 实现康威生命游戏
- 康威生命游戏的简单实现
- 康威生命游戏C语言实现(串行+intrinsics并行)
- 康威生命游戏 Conway's game of life
- 康威生命游戏 第二部分-设置界面和存档功能
- 康威生命游戏 第一部分-基本功能实现(C++ & Windows SDK)
- 操练
- 操练
- 软件工程课后作业—结对编程—生命游戏
- 生命游戏——一个简单的元胞自动机
- 生命游戏
- 生命游戏
- 生命游戏
- 生命游戏
- int, char*, Cstring 的一些转换
- 模型修订失败,“无法将已经有关联的原存储配置的所有者添加到新的原存储配置”
- 冒泡排序C语言实现
- 如何确定域在结构中的字节偏移
- Unable to compile code (__RPC__in)
- 编码操练招式——康威生命游戏
- android怎么在release版下不输出日志?
- document.execCommand()的用法小记
- 【优化】--Memcache优化汇总
- Qt半透明窗口
- 一个svn问题的解决
- MFC下界面切换
- XPath语法 在C#中使用XPath示例
- IOS之播放器