Class: Zindagi

Zindagi

Zindagi represents a life-like cellular automata

new Zindagi (options)

Initializes a life-like cellular automata

Name Type Description
options object optional

Options to pass for initialization

Name Type Default Description
rules object | string B3/S23

Like-like rules eg. B3/S23 or { B: { 3: true }, S: { 2: true, 3: true } }

stitchedEdges boolean false

Enables behavior where the opposite edges seem to be stitched together such that the next cell of the last cell in a row is the first one.

initState string | state optional

Initial state of the automata. Defaults to a random state geenerated depending on the grid option

grid object optional

Options for randomly generated initial state

Name Type Default Description
columns number 10

Number of columns

rows number 10

Number of rows

symbols object optional

Symbols to represent cell types in initState param

Name Type Default Description
alive * ⬛️

Alive cells

dead * ⬜️

Dead cells

rowDelimeter * \n

Represents new row of cells

algorithm string naive

For future use

Classes

Zindagi

Methods

live (generations)state generator

Takes the game forward by n generations. If still life is reached globally, it stops living more generations.

Name Type Default Description
generations number Infinity

Number of generations to live

render (play, options) async

Helper method to print the game on every generation

Name Type Description
play IterableIterator

Return value of live method

options object optional
Name Type Default Description
alive * ⬛️

Symbol to represent alive cells

dead * ⬜️

Symbol to represent dead cells

timePerGeneration number 1

Time in seconds before next generation is rendered

reset ()

Resets the game to initial state

skip (generations)state

Skips n generations ahead

Name Type Description
generations number

Generations to skip

Returns:
Type Description
state The state after skipping