Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/jamen/ca-formats
Decodes cellular automata formats to [x1, y1, ..., xn, yn] values.
https://github.com/jamen/ca-formats
Last synced: 17 days ago
JSON representation
Decodes cellular automata formats to [x1, y1, ..., xn, yn] values.
- Host: GitHub
- URL: https://github.com/jamen/ca-formats
- Owner: jamen
- Created: 2018-02-13T06:26:36.000Z (almost 7 years ago)
- Default Branch: master
- Last Pushed: 2018-02-25T22:02:56.000Z (over 6 years ago)
- Last Synced: 2024-10-20T02:33:50.332Z (25 days ago)
- Language: JavaScript
- Homepage:
- Size: 10.7 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: readme.md
Awesome Lists containing this project
README
# ca-formats (WIP)
Decodes [cellular automata][1] formats to `[x1, y1, ..., xn, yn]` values. It currently supports the types `rle`, `plain`, and `life` (1.05 and 1.06).
## Install
```sh
npm i ca-formats
```## Usage
### `decode.rle(str) -> cells`
### `decode.life(str) -> cells`
### `decode.plain(str) -> cells`
Decodes a string of the given type into an array of interlaced cells.
```js
decode.plain('.OO\nOO\n.O')
// [ 1, 0, 2, 0, 0, 1, 1, 1, 1, 2 ]decode.rle('b2o$2ob$bo!')
// [ 1, 0, 2, 0, 0, 1, 1, 1, 1, 2 ]
```See [`test/`][2] for more examples.
[1]: https://en.wikipedia.org/wiki/Cellular_automaton
[2]: test/