An interactive Conway's Game of Life simulation running on NumPy, Pygame and FastObjects.
1. Go to github release.
- Interactive Canvas: Left-click to draw living cells, right-click to clear them.
- Time Controls: Press Space to freeze time for building, and use keys 1, 2, or 3 to speed up or slow down the simulation loop on the fly.
- Seamless Window Scaling: Supports native window resizing and F11 borderless fullscreen. The simulation auto-extends on the fly, introducing random noise into newly opened space while preserving your existing patterns intact.
- Configuration File: All constants, visual styles, initial scale properties, and custom keybindings are completely isolated within
config.py.
- Python 3.11+
- NumPy
- Pygame
- FastObjects
- Clone the repository:
git clone https://github.com/egraich/PythonLife- Install the required packages:
pip install -r requirements.txt- Start the application:
python main.pyInstead of using slow nested for loops to check every single cell one by one (which lags terribly on large screens), this project uses NumPy matrix math to update everything at once.
The code shifts the entire grid in 8 directions using np.roll() and adds them up. This counts the neighbors for all cells simultaneously. After that, it applies the game rules using basic array masking in a single step. It's way faster and keeps the FPS stable even in fullscreen mode.
Drawing works the same way: instead of looping over live cells with pygame.draw.rect every frame, the whole grid lives in a FastObjects ShapeBatch, and each frame is just one vectorized NumPy write plus a single instanced GPU draw call. Rendering 30k+ cells in fullscreen costs well under a millisecond, so the simulation itself is now the only limit on speed.
- Ruleset based on John Conway's Game of Life.
- Built using the Pygame framework, NumPy, and FastObjects for GPU-accelerated rendering.
Made by egraich