Conway's Game of Life written in Python, using Taichi lang.
- Standard rules
- Finite field as todorial array
- Randomize, clear field
- Pause simulation
- Draw cells
- Field size
- Cell pixel size
- Cells color
- Start condition
- Backend computing
- Profiling
- Field generation
As the project is written in Python, you must have Python interpreter installed on machine to run code.
Important
Not all Python versions work with Taichi. Which specific do are listed on official website. To avoid further conflicts release 3.10.11 is recommended.
To get a local copy of repository open terminal and execute git clone
command:
git clone https://github.com/wivest/Game-of-Life.git
Some external Python packages are required, including Taichi. To install them open cloned directory in terminal:
cd Game-of-Life
Tip
Optional step. Recommended to avoid package versions conflicts.
To manage Python packages virtual environment can be created. More information can be found here.
To collect missing packages execute pip install
command:
pip install -r requirements.txt
Open project folder in terminal and launch main.py
file by executing python
command:
python main.py
- Randomize by pressing
R
key. - Clear by pressing
C
key. - Pause by pressing
Spacebar
key. - Draw by pressing and dragging left mouse button.
- Erase by pressing and dragging right mouse button.
- Change brush size by pressing
UP
andDOWN
keys.
By editing parameters in parameters.json
you can customize behaviour of application. Here available ones for user are listed:
Name | Type | Description |
---|---|---|
columns |
int |
Number of field columns. Default: 1024 |
rows |
int |
Number of field rows. Default: 512 |
size |
int |
Size of a cell in pixels. Default: 1 |
arch |
string |
Backend architecture used by Taichi. Suggested: "gpu" and "cpu" .Default: "cpu" |
profiling |
bool |
Enable profiling of Taichi kernel in form of terminal output. Default: false |
alive |
Array |
Alive cell color in RGB format. Default: [255, 255, 255] |
dead |
Array |
Dead cell color in RGB format. Default: [0, 0, 0] |
highlight |
Array |
Highlighted cell color in RGB format. Default: [50, 50, 50] |
percentage |
float |
Percentage of alive cells when randomizing field. Default: 0.1 |
When using gpu
backend architecture, there might be some cells with corrupted data. To prevent this, avoid fast drawing and large-sized brush. Corrupted cells are highlighted with red color. Reset field to fix data.