freemanvt / gameoflife

game of life node.js implementation

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Game Of Life

My implementation for the Game Of Life

https://en.wikipedia.org/wiki/Conway%27s_Game_of_Life

To run, clone to your desktop and enter

node index

To create your own Game Of Life board. Do the following

var GameOfLife = require('GameOfLife');
// you can pass in the number of rows and columns you want for the board
var gameoflife = new GameOfLife(10, 10);

You can seed the board by getting the board and using setCell on the cells you want to be alive

// set some random cell
gameoflife.getBoard().setCell(1,1,true);
gameoflife.getBoard().setCell(2,2,true);

You can then use call runOnce continuously

e.g.

setInterval(function() {
    gameoflife.runOnce();
    console.log(gameoflife.getBoard().printBoard() + "\n\n");
}, 1000);

About

game of life node.js implementation


Languages

Language:JavaScript 100.0%