zindagi

1.0.2 • Public • Published

Zindagi

build status coverage status npm version license

Zindagi is a library to easily program and render life-like cellular automatas including but not limited to Highlife and Conway's Game of Life.

Usage

import { Zindagi } from 'zindagi';        // use ES modules
// const { Zindagi } = require('zindagi); // or CommonJS
 
const life = new Zindagi({
  // Life-like rule
  rules: 'S23/B3',
  // Flag to enable alive cells to re-appear on
  // the other side of the board in case of overflow
  stitchedEdges: true,
  // Symbols to represent alive and dead cells in initState param
  symbols: {
    alive: '0',
    dead: '.'
  },
  // Initial state of the automata
  initState: `..........
              .0........
              ..00......
              .00.......
              ..........
              ..........
              ..........
              ..........`
});
 
// play for 1000 generations
const generations = life.live(1000);
 
// in built method to render the automata to console/terminal
life.render(generations, {
    alive: '⬛️',            // represent alive cells with black block
    dead: '⬜️',             // represent dead cells with white block
    timePerGeneration: 0.5, // 0.5 seconds per generation
});

Output

Example Output

Install

npm install zindagi

TODO

  • Documentation
  • Tests
  • Optimizations

Package Sidebar

Install

npm i zindagi

Weekly Downloads

1

Version

1.0.2

License

MIT

Unpacked Size

32.4 kB

Total Files

8

Last publish

Collaborators

  • tbking