This is a simple implementation of Conway's Game of Life.
To run it, clone this project and run ./frames.csh <imagename> <rule> <frames>
The image must be a ppm format file. There's some examples in ./testInputs
Here's how rule is defined, using the rule 0x1808
as an example:
If a cell's state is... | alive (1) | dead (0) | ||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
And the number of alive neighbors is... | 8 | 7 | 6 | 5 | 4 | 3 | 2 | 1 | 0 | 8 | 7 | 6 | 5 | 4 | 3 | 2 | 1 | 0 |
Then the cell's next state is... | 0 | 0 | 0 | 0 | 0 | 1 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 |
Converting the 18 bits above to a hexadecimal number | 0b00 0001 1000 0000 1000 0x1808 |
<frames>
determines how many steps of the simulation you want to have in your ouput gif