Conway's Game of Life is a classic one player game/simulation. Read more about it on Wikipedia.
The simulator comes with the following features:
- Zoomable and scrollable simulation playground
- Optimized simulator which only simulates areas with live cells
- Random board generation
- Toggleable Grid Lines
- PNG Capturing of current board state
- Save the current board state and load it in later
- Record the board during animation and convert to video
When the user presses the Save
button, the current state of the board will be saved in a golf
(G
ame O
f L
ife F
ile) file with the following format:
SIZE
index1
index2
index3
...
where SIZE
is the size of the board (the board is always a SIZE
by SIZE
square) and index1
, index2
, index3
, ... represent the indices where cells are alive. The indices are flattened. Given an x
coordinate and a y
coordinate on a board with size size
, the formula to calculate the coordinate is coordinate = x * size + y
. If you'd like to create your own designs and load them into the simulator, simply create a file in the format above, where you specify the size of your square board and the coordinates of every square you'd like to be alive.
These files are saved in the Saved
directory which is automatically generated on startup.
The .golfr
file format is the s file format used to store multiple frames of simulation. The file format is the same as the .golf
format, without the SIZE
parameter at the front. The SIZE
is specified on the first line of this file. It simply stores the coordinates of each cell as a comma separated list on every line in the file.
These files are saved in the Recordings
directory which is automatically generated on startup.
Once the user presses the Record
button, a file called Recording{X}.golfr
(X
is a number) is created. This file will contain the state of the board for every frame that was recorded. To convert this file to a video format, use convert.py
.
convert.py
usage:
cd Recordings
python convert.py -f FILENAME -t TYPE -r RESOLUTION -fps FPS
usage: convert.py [-h] [-f FILENAME] [-t TYPE] [-r RESOLUTION] [-fps FPS]
Convert recorded .golfr files into video.
optional arguments:
-h, --help show this help message and exit
-f FILENAME, --filename FILENAME The filename of the .golf file to convert.
-t TYPE, --filetype TYPE The file type of video to convert to.
-r RESOLUTION, --resolution RESOLUTION The size of the cells in the video.
-fps FPS, --fps FPS The frames per second of the video.
convert.py
dependencies:
Python 3.7+
numpy
imageio
tqdm
Note that convert.py
is just one way of converting the data into video form. Modify the script to customize the video you get out of it.