Giter VIP home page Giter VIP logo

game-of-life's Introduction

Game of life - 生命游戏

关于生命游戏

康威生命游戏(英语:Conway's Game of Life),又称康威生命棋,是英国数学家约翰·何顿·康威在1970年发明的细胞自动机。它最初于1970年10月在《科学美国人》杂志上马丁·葛登能的“数学游戏”专栏出现。 ——维基百科

维基百科链接Conway's Game of Life

简而言之就是,在一个二维空间内每一个格子就是一个「细胞」,每个细胞存在着两种状态,生和死,并通过一定的规则进行演算的结果。结果如下

运行结果

规则

最为经典的「B3S23」

  • 当前细胞为存活状态时,当周围八个细胞低于2个(不包含2个)存活细胞时, 该细胞变成死亡状态。(模拟生命数量稀少)
  • 当前细胞为存活状态时,当周围八个细胞有2个或3个存活细胞时, 该细胞保持原样。
  • 当前细胞为存活状态时,当周围八个细胞有3个以上的存活细胞时,该细胞变成死亡状态。(模拟生命数量过多)
  • 当前细胞为死亡状态时,当周围八个细胞有3个存活细胞时,该细胞变成存活状态。 (模拟繁殖)

就这样简单的规则和初始状态决定了生命游戏的发展。

特性

  • 使用C++进行编写
  • 支持通用RLE模式文件
  • 模拟结果保存为PPM图片
  • 通过简单的命令行参数设置模拟用的模式文件和模拟次数

怎么构建

请确认您已经安装了make和支持C++11的C++编译器(默认使用g++,可以在Makefile修改)

  1. 下载.zip或是git clone把代码下载下来。
  2. 进入目录,使用make命令进行构建,构建成功后可以使用make clean把编译过程中的.o文件删除。
  3. 接下来你就可以使用Pattern文件夹中的RLE文件,或者你自己的RLE文件去simulate the world了。

怎么使用

./Game.out -p [RLE文件] -t [模拟次数]
Example:
    ./Game.out -p Pattern/otcametapixel.rle -t 100

Have a good time.

感谢

感谢LifeWiki完整的各种资料,包括且不限于:

  1. 完整的RLE文件格式文档。
  2. 巨量的RLE模式文件总计2000+,和各个模式的资料。

最后

邮箱 [email protected]

博客 Tom smith

game-of-life's People

Contributors

shuaitq avatar

Stargazers

Daniel Heart avatar nber1994 avatar 逆旅 avatar ChingRu avatar lxdlam avatar  avatar Yuchen Song avatar Jingyuan Yi avatar  avatar 云昴 avatar  avatar

Watchers

James Cloos avatar  avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.