0.2.4 • Public • Published

    Conway's Game of life Build Status npm version

    ES6 JavaScript algorithm implementation.


    You can install Game of life using npm:

    npm install -g game-of-life-es6



    var GameOfLife = require('game-of-life-es6'),
      world = new GameOfLife.World(1, 1);


    <script src="dist/bundle.js"></script>
      var world = new GameOfLife.World(1, 1);


    Please check API Documentation for more details.


    The universe of the Game of Life is an infinite two-dimensional orthogonal grid of square cells, each of which is in one of two possible states, alive or dead. Every cell interacts with its eight neighbours, which are the cells that are horizontally, vertically, or diagonally adjacent. At each step in time, the following transitions occur:

    • Any live cell with fewer than two live neighbours dies, as if caused by under-population.
    • Any live cell with two or three live neighbours lives on to the next generation.
    • Any live cell with more than three live neighbours dies, as if by overcrowding.
    • Any dead cell with exactly three live neighbours becomes a live cell, as if by reproduction.

    The initial pattern constitutes the seed of the system. The first generation is created by applying the above rules simultaneously to every cell in the seed—births and deaths occur simultaneously, and the discrete moment at which this happens is sometimes called a tick (in other words, each generation is a pure function of the preceding one). The rules continue to be applied repeatedly to create further generations.

    Good coding pratices

    According to Kent Back four rules for a simple system are in order (most important first):

    1. Run all the tests
    2. Contain no duplicate code
    3. Express all the ideas the author wants to express
    4. Minimize classes and methods

    SOLID principles:

    1. Single Responsibility (SRP): A class (component) should have one, and only one, reason to change.
    2. Open-Closed (OCP): A system should be open for extension, but closed for modification.
    3. Liskov Substitution (LSP): Derived types should be substitutable for their base types.
    4. Interface Segregation (ISP): Abstractions should not depend upon details. Details should depend upon abstractions.
    5. Dependency Inversion (DIP): Interfaces should be small, focused on a specific use case.

    The DRY (Don't Repeat Yourself) Principle states:

    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.



    • Node 0.12.x or io.js 1.x
    • grunt-cli: run npm install -g grunt-cli if needed.
    • Windows only: remember to set Git and Node path in environment variable %PATH%.

    Grunt tasks

    • grunt dependencies - helps to update package.json file
    • grunt spec - lints the code and runs unit tests
    • grunt build - lints the code, runs unit tests, creates dist/bundle.js transformed ES5 code
    • grunt - runs grunt build

    Useful Links




    Grunt tasks


    npm i game-of-life-es6

    DownloadsWeekly Downloads






    Last publish


    • gziolo