Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/deviousasti/gameoflife-wasm
Conway's Game of Life in Web Assembly, built using Bolero
https://github.com/deviousasti/gameoflife-wasm
Last synced: 3 months ago
JSON representation
Conway's Game of Life in Web Assembly, built using Bolero
- Host: GitHub
- URL: https://github.com/deviousasti/gameoflife-wasm
- Owner: deviousasti
- Created: 2020-06-13T10:47:30.000Z (about 4 years ago)
- Default Branch: master
- Last Pushed: 2020-06-14T20:13:42.000Z (about 4 years ago)
- Last Synced: 2024-01-19T17:12:10.868Z (6 months ago)
- Language: F#
- Homepage: https://asti.dynz.net/gameoflife-wasm/
- Size: 3.52 MB
- Stars: 31
- Watchers: 2
- Forks: 3
- Open Issues: 2
-
Metadata Files:
- Readme: Readme.md
Lists
- awesome-bolero - Game of Life - A game of life implementation in Bolero Elmish (Examples)
README
# Conway's Game of Life
This is an implementation of Conway's Game of Life in F# using [Bolero](https://github.com/fsbolero/Bolero), which runs a compiled F# assembly entirely in Web Assembly. This is different from [F# Fable](https://fable.io) which transpiles to Javascript.
There are no limitations on what portions of the library are available, rather any library can be used in Bolero, as evidenced by the use of `Array2D` functions.
![recording](https://user-images.githubusercontent.com/2375486/84602711-f5cedb00-aea6-11ea-8b60-720467cfdf9d.gif)
## Implementation
There is no HTML component; the entire Model-View-Update (MVU) application is written in Elmish in `Main.fs`.
The model is immutable, so all updates are transformations. (most implementations which use double-buffering and array mutations).## Observations
Interop with the JS runtime seems to be expensive, while calculating the diff is not costly.
The internal state is a 2D array. Since model state in Elmish is never mutated, it must be recreated every time.
```
{ model with state = state |> Array2D.mapi(fun i j _ -> alive i j state |> rules) }
```
So enough memory pressure is generated to cause a GC.![image](https://user-images.githubusercontent.com/2375486/84602915-324f0680-aea8-11ea-99d0-67e59c105e63.png)
This is a minor GC and very fast (less than 1ms).