Key Features 🍪 | Requirements 🧬 | Build and Run 🚀 | Controls 📃 | Credits ✍
Cell data (such as color, number of alive neighbors, etc.) is packed in a single 32-bit unsigned integer. Used for saving memory and simplifying the algorithm for next epoch generation.
00000000 | 00000000 | 00000000 | 000 | 0000 | 0 |
---|---|---|---|---|---|
R channel | G channel | B channel | Unused bits | Alive neighbors | Is alive |
You can see the exact implementation in cells.h file.
Current epoch is stored in buffer before the new one is generated, so you are able to return to previous generation(s) or undo changes.
You can see the exact implementation in gens_buffer.h file.
Buffer size is 128 by default (which means that it can hold current generation and 127 previous generations). You can change it in preference file.
When cell becomes a live cell on next generation we need to assign color to it. My approach is to get average color of all alive neighbor cells.
You can see the exact implementation in generateCellHexColor
function in cells.h file.
You can also customize preferences before compilation by modifying prefs.h file.
No actions needed.
Download and install libsdl2-dev via your package manager, for example:
sudo apt install libsdl2-dev
mkdir build
cd build
cmake .. && make all
./DrawOfLife
- Left mouse button click (hold) on grid: Draw with selected color (mark cell(s) as alive).
- Left mouse button click on color palette: Change draw color.
- Right mouse button click (hold) on grid: Erase (mark cell(s) as dead).
- Left arrow / Right arrow: Change draw color.
- Up arrow / Down arrow: Next / previous generation.
- G: Toggle grid.
- C: Clear all (mark all cells as dead).
- Space: Start / stop animation with generating next epochs.
- Esc: Close app.
- Ivan Menshikov (menshiva@fit.cvut.cz)