Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/edegan-furb/conwaygameoflife
This project is a simulation of Conway's Game of Life using Python with the Pygame library.
https://github.com/edegan-furb/conwaygameoflife
conways-game-of-life numpy pygame python
Last synced: 12 days ago
JSON representation
This project is a simulation of Conway's Game of Life using Python with the Pygame library.
- Host: GitHub
- URL: https://github.com/edegan-furb/conwaygameoflife
- Owner: edegan-furb
- Created: 2024-08-10T23:52:08.000Z (3 months ago)
- Default Branch: main
- Last Pushed: 2024-08-12T04:13:00.000Z (3 months ago)
- Last Synced: 2024-08-13T02:33:45.036Z (3 months ago)
- Topics: conways-game-of-life, numpy, pygame, python
- Language: Python
- Homepage:
- Size: 1.62 MB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Conway's Game of Life Simulation
This project is a simulation of Conway's Game of Life using Python with the Pygame library. It visualizes the cellular automaton on a grid and allows for interactive manipulation of cells. The game rules and simulation can be controlled through keyboard and mouse inputs.
## Requirements
- Python 3.x
- Pygame
- NumPyYou can install the required packages using pip:
```bash
pip install pygame numpy
```## How It Works
### Game of Life Rules
Conway's Game of Life is a zero-player game where the evolution of cells is determined by the following rules:
1. Any live cell with fewer than two live neighbors dies as if caused by under-population.
2. Any live cell with two or three live neighbors lives on to the next generation.
3. Any live cell with more than three live neighbors dies, as if by over-population.
4. Any dead cell with exactly three live neighbors becomes a live cell, as if by reproduction.### Simulation Controls
- Spacebar: Toggle the simulation between running and paused states.
- C key: Clear the grid, setting all cells to dead.
- R key: Repopulate grid with random cells
- Left Mouse Button: Toggle the state of a cell (alive or dead) by clicking on the grid.### Running the Simulation
To run the simulation, execute the script:```bash
python main.py
```The Pygame window will open, displaying the grid and the current state of the cells.
## Code Overview
- **update(screen, cells, size, with_progress=False)** : Updates the grid based on Conway's Game of Life rules and draws the cells on the screen.
- **main()** : Initializes Pygame, sets up the display window, and handles the main event loop for user interactions and simulation updates.