https://github.com/threepointone/game-of-life
generic game of life algorithm implementation in javascript
https://github.com/threepointone/game-of-life
Last synced: 2 months ago
JSON representation
generic game of life algorithm implementation in javascript
- Host: GitHub
- URL: https://github.com/threepointone/game-of-life
- Owner: threepointone
- Created: 2013-01-31T17:16:50.000Z (over 12 years ago)
- Default Branch: master
- Last Pushed: 2013-03-21T02:30:22.000Z (about 12 years ago)
- Last Synced: 2025-01-25T08:11:38.268Z (4 months ago)
- Language: JavaScript
- Size: 141 KB
- Stars: 1
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: Readme.md
- Changelog: History.md
Awesome Lists containing this project
README
# game-of-life
A generic Game Of Life implementation in javascript
## Installation
$ component install threepointone/game-of-life
## API
```js
var grid = require('game-of-life')({
width: 100,
height: 20
});// prepopulate some cells with live state
for(var i = 0; i < 200; i++) {
var x = Math.ceil(Math.random() * 100);
var y = Math.ceil(Math.random() * 20);
grid.at(x, y, true);
}setInterval(function() {
grid.step();
console.log(grid.str());
}, 100);// grid.at(x,y) will get you life/death at every cell.
```
```
....................................................................................................
..............................................................OO....................................
.............................................................O..OOOOOO..............................
.............................................................O.OOO....O.............................
.................................................O............O..OOO...O............................
................................................O.O.................O..O............................
................................................O.O..................O..O...........................
.................................OO..............O..................O..O............................
................................O..O.................................O.O...O........................
.................................OO.......................................O.OO......................
.........................................................................OO.OO......................
..........................................................................O...OO....................
..............................................................................OO....OO..............
...........................................................................OOOOO....OO..............
......................................................................OOO...........................
.......................................................................OO...........................
........................O...............................................O...........................
........................O....................................................O......................
........................O.............OO..................................O..O......................
......................................OO...............................OO.O.O.......................```
## License
MIT