octo-game-of-life
v1.1.0
Published
> Initiate and simulate several generations according to the rules > of Conway's game of life
Downloads
7
Readme
Game of Life logic
Initiate and simulate several generations according to the rules of Conway's game of life
This package has been written collectively by the Skool9 promotion at OCTO
Installation
$ npm install
or
$ yarn install
Launch test
$ npm test
$ yarn test
API
Generation
Contains an image of the world at a given generation. All its alive cells.
new Generation()
Creates an empty generation. No cells alive.
new Generation(Cells[])
Creates a generation containing these alive cells.
.next(): Generation
Returns the next generation according to Conway's game of life
.cellCount: number
Returns the number of alive cells in this generation.
.dimensions: { width: number, height: number }
The dimensions of the grid
.hasLivingCellAt(x, y): boolean
Returns true if this position contains a living cell in this generation.
.hasLivingCellAt(location): boolean
Returns true if this position contains a living cell in this generation.
Cell
Represents a living cell at a given position
new Cell(x: number, y: number)
Creates a living cell at the given coordinates
Location
Represents a location on the world (mostly internal usage)
Technologies
- tests in
mocha
andchai
- code in
typescript