Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

game-of-life-es6

Package Overview
Dependencies
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

game-of-life-es6

Conway's Game of life - ES6 JavaScript algorithm implementation

  • 0.2.4
  • latest
  • npm
  • Socket score

Version published
Weekly downloads
7
Maintainers
1
Weekly downloads
 
Created
Source

Conway's Game of life Build Status npm version

ES6 JavaScript algorithm implementation.

Installation

You can install Game of life using npm:

npm install -g game-of-life-es6

Usage

Node
var GameOfLife = require('game-of-life-es6'),
  world = new GameOfLife.World(1, 1);
Browser
<script src="dist/bundle.js"></script>
<script>
  var world = new GameOfLife.World(1, 1);
</script>

API

Please check API Documentation for more details.

Rules

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.

Contributing

Requirements

  • 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

General

Design

ES6

Grunt tasks

Keywords

FAQs

Package last updated on 14 Apr 2015

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc