An ES6 implementation of Conway's Game of Life. Given it's current state, calling #next will return a new instance
of the game initialized with the next state. In that sense, the game works as a stream of essentially immutable states.
HERE is a basic example of an EmberJS app utilizing ConwayJS
npm install --save conwayjs const Conway = ; // create a new game instance. let conway = ; // get the current game board (2D array of 0s ad 1s) let board = conwayboard; // get the next game instance conway = conwaynext;The default board size is 100x100. You can pass in an instance of your own if you wish in the following way:
// create a new game instance with a game board that is 50x50 let conway = Conway;When you create a new game instance it will automatically get populated with a random set of living and dead cells. You can disable that if you wish:
let conway = Conway; You can influence the state of game like so:
let conway = ; let row = 0; let column = 1; // check if a given cell is alive conway; // toggle the state of a cell conway; // revive a cell conway; // kill a cell conway;Print the current board to console:
let conway = ; conway;