|
1 |
| -Readme text goes here |
| 1 | +# Life |
2 | 2 |
|
| 3 | +[Conway's Game of Life](https://en.wikipedia.org/wiki/Conway%27s_Game_of_Life) visualizer tool built with |
| 4 | +[Elixir](https://elixir-lang.org/) and [Scenic.](https://github.com/boydm/scenic) |
3 | 5 |
|
4 |
| -From template |
| 6 | +## Sample |
| 7 | + |
| 8 | +Flyer Generator |
| 9 | + |
| 10 | + |
| 11 | + |
| 12 | +Pulsar Oscillator |
| 13 | + |
| 14 | + |
| 15 | + |
| 16 | +## Explanation |
| 17 | + |
| 18 | +In the Game of Life, a board has cells that are either alive or dead. Given a set of rules, the board will change. All |
| 19 | +changes for a given iteration/tick happen simultaneously on the previous board status. This means that any changes to |
| 20 | +the cells during the current iteration will be influence the other cells. |
| 21 | + |
| 22 | +## Rules |
| 23 | + |
| 24 | +The rules of Conway's Game of Life are very simple, |
| 25 | + |
| 26 | +1. any live cell with two or three live neighbors remain alive, |
| 27 | +2. any live cell with fewer than two live neighbors dies (simulating underpopulation), |
| 28 | +3. any live cell with greater than three live neighbors dies (simulating overpopulation), |
| 29 | +4. any dead cell with exactly three live neighbors become a live cell (simulating reproduction) |
| 30 | + |
| 31 | +## Using the visulizer |
| 32 | + |
| 33 | +**Important** Unfortunately, due to limitations of Scenic, the visualizer can only run on Mac OS and Linux. |
| 34 | + |
| 35 | +Ensure that Elixir and any [dependency of Scenic](https://hexdocs.pm/scenic/install_dependencies.html) is installed. |
| 36 | + |
| 37 | +```bash |
| 38 | +git clone https://github.com/woojiahao/life.git |
| 39 | +cd life/ |
| 40 | +mix deps.get |
| 41 | +mix scenic.run |
| 42 | +``` |
| 43 | + |
| 44 | +Select the cells to set them as alive/dead before running. |
| 45 | + |
| 46 | +## Configuration |
| 47 | + |
| 48 | +You can configure the board size and initial pattern by editing the `config/attrs.exs` file, under the `:attrs` config. |
| 49 | + |
| 50 | +```elixir |
| 51 | +import Config |
| 52 | + |
| 53 | +# Configure here |
| 54 | +config :life, :attrs, %{ |
| 55 | + cell_size: 20, |
| 56 | + evolution_rate: 100, |
| 57 | + pattern: :empty |
| 58 | +} |
| 59 | +``` |
| 60 | + |
| 61 | +1. `cell_size` -- size of each cell displayed |
| 62 | +2. `evolution_rate` -- speed each iteration occurs, measured in milliseconds |
| 63 | +3. `pattern` -- some default oscillating patterns to get started, includes `:blinker`, `:beacon`, `:pulsar`, `:toad`, `:empty` |
0 commit comments