JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 4
  • Score
    100M100P100Q48032F
  • License ISC

Game of Life with support for arbitrary world rules

Package Exports

  • gameoflife-rulestring

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (gameoflife-rulestring) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

js-gameoflife

Game of Life

###@Constructor

World - Represents a World.
@constructor
@return {object} World

###@Typedef

@typedef {state: {bool}} Cell
@typedef {row: {number}, col: {number}} Location
@typedef {survival: {string}, born: {string}} rules

###@Public API Methods:

  • World.init({string}, {string}) - Initializes the World with board and rules.
  • World.getCell({Location})
  • World.setCell({Location}, {Cell})
  • World.getRules()
  • World.getGeneration()
  • World.getAliveCount()
  • World.getRows()
  • World.getCols()
  • World.evolve()
  • World.toString()
  • World.inBound({Location})

###Example:

$ > var world = new World();
$ > var ruleString = '23/3'; (B3/S23 - Conway's Life)
 
$ > var board = '......\n' +
                 '***...\n' +
                 '......\n' +
                 '......\n' +
                 '......\n' +
                 '......\n';
 
$ > world.init(board, ruleString);
$ > world.evolve();
$ > console.log(world.toString());
 
. * . . . .
. * . . . .
. * . . . .
. . . . . .
. . . . . .
. . . . . .

##License

Free to use and abuse under the MIT license. http://www.opensource.org/licenses/mit-license.php