Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/yoannchb-pro/game-of-life
Game of life algo
https://github.com/yoannchb-pro/game-of-life
algorithm canvas game game-of-life life
Last synced: 23 days ago
JSON representation
Game of life algo
- Host: GitHub
- URL: https://github.com/yoannchb-pro/game-of-life
- Owner: yoannchb-pro
- License: mit
- Created: 2022-08-31T15:42:32.000Z (about 2 years ago)
- Default Branch: main
- Last Pushed: 2022-11-16T19:51:06.000Z (almost 2 years ago)
- Last Synced: 2024-01-27T07:07:19.035Z (10 months ago)
- Topics: algorithm, canvas, game, game-of-life, life
- Language: HTML
- Homepage:
- Size: 4.88 KB
- Stars: 0
- Watchers: 2
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Game-of-life
Game of life algo
> Note: See example [here](https://yoannchb-pro.github.io/game-of-life/index.html)
## Import
```html
```
## How to use
There are two arguments `nbCelssWidth` and `nbCellsHeight` (by default 50 and 50) for the number of cells you want on the width and on the height
```js
const handler = new GameOfLife(3, 3);
console.log(handler.game);
//[[0, 0, 0], [0, 0, 0], [0, 0, 0]]
```### Random generation
There is one argument `factor` (by default 0.2) between 0 and 1 that determine the probability of a cell to be alive
```js
handler.randomGeneration();
//[[0, 0, 1], [1, 0, 1], [1, 0, 0]]
```### Evoluate
Evoluate the environment
```js
//[[0, 1, 0], [0, 1, 0], [0, 1, 0]]
handler.evoluate();
//[[0, 0, 0], [1, 1, 1], [0, 0, 0]]
```### Hydratate
There are two arguments `line` and `column`
```js
handler.hydratate(1, 2);
//[[0, 0, 0], [0, 0, 1], [0, 0, 0]]
```### Deshydratate
There are two arguments `line` and `column`
```js
//[[0, 0, 0], [0, 0, 1], [0, 0, 0]]
handler.deshydratate(1, 2);
//[[0, 0, 0], [0, 0, 0], [0, 0, 0]]
```### Clear
Clear the whole environment
```js
//[[0, 1, 0], [0, 1, 0], [0, 1, 0]]
handler.clear();
//[[0, 0, 0], [0, 0, 0], [0, 0, 0]]
```