1.0.4 • Published 7 years ago

lifegame v1.0.4

Weekly downloads
2
License
ISC
Repository
github
Last release
7 years ago

lifegame(生命游戏)

Build Status Coveage npm version download license

每个格子的生死遵循下面的原则:

  1. 如果一个细胞周围有3个细胞为生(一个细胞周围共有8个细胞),则该细胞为生(即该细胞若原先为死,则转为生,若原先为生,则保持不变) 。

  2. 如果一个细胞周围有2个细胞为生,则该细胞的生死状态保持不变;

  3. 在其它情况下,该细胞为死(即该细胞若原先为生,则转为死,若原先为死,则保持不变)

用法:

npm install lifegame

const {nextMap} = require('lifegame')
const map = [[1,1,1],[1,1,1],[1,1,1]]
const newmap = nextMap(map)
console.log(newmap) // newmap tobe [[1,0,1],[0,0,0],[1,0,1]]
const {nextMap} = require('lifegame')
const newmap = initMap(3,4)
console.log(newmap) // newmap tobe 3*4 map
1.0.4

7 years ago

1.0.3

7 years ago

1.0.2

7 years ago

1.0.1

7 years ago

1.0.0

7 years ago

0.1.2

7 years ago

0.0.2

7 years ago

0.0.1

7 years ago