Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/itsnickbarry/game-of-life
Sorry, John Conway
https://github.com/itsnickbarry/game-of-life
life wow
Last synced: 14 days ago
JSON representation
Sorry, John Conway
- Host: GitHub
- URL: https://github.com/itsnickbarry/game-of-life
- Owner: ItsNickBarry
- License: mit
- Created: 2015-11-10T05:39:11.000Z (about 9 years ago)
- Default Branch: gh-pages
- Last Pushed: 2016-09-16T05:02:00.000Z (over 8 years ago)
- Last Synced: 2024-11-07T04:47:05.427Z (2 months ago)
- Topics: life, wow
- Language: CSS
- Homepage: https://itsnickbarry.github.io/game-of-life
- Size: 34.2 KB
- Stars: 0
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.md
Awesome Lists containing this project
README
# The Game of Life
One of [John Conway's][conway] great contributions to the field of combinatorial game theory, as well as one of his many regrets.This implementation of the [Game of Life][gol] is projected onto a toroidal surface.
Take a look at the [project site][gh-pages].
[conway]: https://en.wikipedia.org/wiki/John_Horton_Conway
[gol]: https://en.wikipedia.org/wiki/Conway's_Game_of_Life
[gh-pages]: https://ItsNickBarry.github.io/game-of-life# Usage
To embed the Game of Life on your website, for whatever reason, first add the scripts in the `lib` directory:```html
```
Use a custom script to initialize a `GameOfLife.Game` object:
```javascript
GameOfLife.game = new GameOfLife.Game(options);
```The constructor accepts an options hash, which may contain the following properties:
###### height
The number of rows on the board; default 30
###### width
The number of columns on the board; default 30
###### defaultPopulationDensity
The probability that each cell will be live when generated; default .3
###### boardElement
The DOM element into which the board will be appended
###### clearElement
The DOM element which, when clicked, will clear the board
###### counterElement
A DOM element which will be updated to display how many in-game generations have passed
###### resetElement
A DOM element which, when clicked, will reset the game
###### tickElement
A DOM element which, if the game is paused, will progress the game by one generation
###### toggleElement
A DOM element which will start or pause the game
###### tickInterval
The time, in milliseconds, between each game tick; default 100
###### clickToToggle
A boolean specifying whether cells may be toggled by clickingDOM elements which are not present in the options hash will be generated by the game. They may be accessed through the following functions:
```javascript
Game.prototype.getBoardElement();
Game.prototype.getCounterElement();
Game.prototype.getResetElement();
Game.prototype.getTickElement();
Game.prototype.getToggleElement();
```Style the board with CSS rules for the following classes. Style should be limited to visual effects; page flow should not be modified:
```css
.gol-board {
/*the board*/
}
.gol-row {
/*a row of cells on the board*/
}
.gol-cell {
/*a cell on the board*/
}
.live {
/*a live cell*/
}
.active {
/*the toggleElement when the game is running*/
}
```# Acknowledgment
The project site is made with [Skeleton][skeleton], which is released by David Gamache under the [MIT license][mit].It makes use of icons from [Font Awesome][fontawesome], which are released under the [SIL Open Font License][sil].
[skeleton]: getskeleton.com
[mit]: http://www.opensource.org/licenses/mit-license.php
[fontawesome]: http://fontawesome.io/
[sil]: http://scripts.sil.org/cms/scripts/page.php?site_id=nrsi&id=OFL