https://github.com/llgaetanll/ca-to-gol
Any Cellular Automaton rule fed as input to Conway's Game of Life
https://github.com/llgaetanll/ca-to-gol
cell game-of-life golang graphics math
Last synced: 3 months ago
JSON representation
Any Cellular Automaton rule fed as input to Conway's Game of Life
- Host: GitHub
- URL: https://github.com/llgaetanll/ca-to-gol
- Owner: llGaetanll
- Created: 2020-12-19T21:21:41.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2023-01-09T18:14:16.000Z (over 3 years ago)
- Last Synced: 2025-04-03T01:44:17.880Z (over 1 year ago)
- Topics: cell, game-of-life, golang, graphics, math
- Language: Go
- Homepage:
- Size: 9.77 KB
- Stars: 2
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Elementary Cellular Automata to Conway's Game of Life

Any Cellular Automaton rule fed as input to Conway's Game of Life. This project is inspired by [this amazing video](https://www.youtube.com/watch?v=IK7nBOLYzdE) by Elliot Waite.
This version of the program is not limited to rule 30, and can generate any of the 256 rules possible from [elementary cellular automata](https://en.wikipedia.org/wiki/Elementary_cellular_automaton).
## Running the Code
Make sure you have Go installed on your system
```
go run *.go
```
This should take some time as go collects the various files used by `sdl`, which is the rendering engine used in the program.
## Parameters
You can tweak the following output parameters. These can be found at the top of the `main.go` file.
- `cellSize`: The sidelength in pixels of the cells of the output grid.
- `cellCountX`: The width of the output grid in cells
- `cellCountY`: The height of the output grid in cells
- `divisionY`: The layer at which the board rules change from Elementary Cellular Automata to Conway's Game of Life
- `frameSleepTime`: How long the program should halt between each frame. Allows to speed up or slow down the output
- `rule`: The Elementary Cellular Automaton rule number to generate at the bottom of the grid
Note that you'll have to restart the program everytime you want these changes to take effect.
## Notes
The colors can also be changed, the list can be found at the top of the `main` function in `main.go`
```go
func main() {
p := []color{
0xffffff01, // first color is a live cell
0x711C9108, // ...everything here is dead
0xea00d91b, // and solely for aesthetic
0x0adbc640, // purposes.
0x133ea47d,
0x00000001, // last color is black with step=1
}
// ...
}
```
Each color is specified as a hex value. The given channels are `RGBA`.