octo-game-of-life

1.1.0 • Public • Published

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 and chai
  • code in typescript

Readme

Keywords

none

Package Sidebar

Install

npm i octo-game-of-life

Weekly Downloads

0

Version

1.1.0

License

MIT

Unpacked Size

44.4 kB

Total Files

27

Last publish

Collaborators

  • floby