Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/edvincandon/rxoflife

πŸ‘Ύ game of life implementation in RXJS
https://github.com/edvincandon/rxoflife

reactive-programming rxjs

Last synced: 27 days ago
JSON representation

πŸ‘Ύ game of life implementation in RXJS

Awesome Lists containing this project

README

        

# πŸ‘ΎπŸ‘ΎπŸ‘Ύ RXofLife πŸ‘ΎπŸ‘ΎπŸ‘Ύ
Game of life implementation in RXJS using canvas rendering. Could probably be optimized. **No for loops**.

## Baking the cake
```shell
npm install
npm run dev # start the dev server
```
#### Tweak `MAX_CELLS` in `src/index.js` at your own risk to increase the max number of cells to be spawned. It defaults to 100,000.

*Chrome might throw a fit and warn you about requestAnimationFrame handler violations - he's a nasty little lad*

## Deep dive
```shell
src
β”‚
β”‚-- index.js # streams and what not
β”‚-- renderer.js # canvas rendering
β”‚-- utils.js # all of them nasty functions
β”‚-- shapes.js # custom shapes represented as lists of coords

```

### Everything is a stream
Think of the game of life as a stream `reducing` over itself. The implementation is a little more complicated in order to optimize the rendering, but you get the idea.
```shell
------x-----------------------x----------------x->
[ 0, 0, 1, 0, [ 0, 0, 0, 0,
0, 0, 1, 0, ---> 0, 1, 1, 1, ---> ...
0, 0, 1, 0, 0, 0, 0, 0,
0, 0, 0, 0 ] 0, 0, 0, 0 ]
```

Oh and **no unit-tests**, sooooorry.
> "Testing is a poor substitute for proof" - Bartosz Milewski

## Todo
- [ ] Add dropdown menu to select shapes