Repository: https://github.com/James-HoneyBadger/LifeGrid
git clone https://github.com/James-HoneyBadger/LifeGrid.git
An interactive Tkinter-based workbench for experimenting with cellular automata. The simulator ships with several classic rules, a custom B/S rule editor, drawing tools, and quick exporting to PNG.
- Multiple automata: Conway's Life, HighLife, Immigration, Rainbow, Langton's Ant, and fully custom life-like rules.
- Pattern presets per mode for quick experimentation.
- Drawing tools with toggle/pen/eraser modes plus symmetry helpers.
- Live statistics for population deltas, peaks, and density.
- Save/Load patterns as JSON and export PNG snapshots (when Pillow is installed).
- Keyboard shortcuts:
Space(start/stop),S(step),Left(step back),C(clear),G(toggle grid).
- Python 3.13+
- Tkinter (bundled with most Python installations)
- NumPy 1.24+
- SciPy 1.11+ (used for fast convolutions)
- Pillow 10+ (optional, enables PNG export)
Install dependencies from the repository root:
pip install -r requirements.txtRun LifeGrid from the project root:
python src/main.pyOr use the helper script on Unix-like systems:
./run.shQuick workflow
- Pick a mode from the Mode dropdown.
- Choose a Pattern or draw on the canvas.
- Press Start (or hit
Space) to run the simulation. - Adjust Speed, drawing tools, and symmetry as needed.
- Use Settings → Grid & View Settings… for grid size, cell size, and grid lines.
- Save/load/export from the File menu.
| Action | UI Control | Shortcut |
|---|---|---|
| Start/Stop simulation | Start button | Space |
| Step one generation | Step button | S |
| Step back one generation | Back button | Left |
| Clear grid | Simulation → Clear | C |
| Toggle grid lines | Settings → Toggle Grid | G |
| Resize grid | Settings → Grid & View Settings… | – |
| Apply custom B/S rule | Settings → Custom Rules… | – |
Mouse interactions:
- Click to toggle/draw/erase (depends on draw mode).
- Drag while in Pen or Eraser to paint continuously.
- Symmetry options mirror strokes across selected axes.
- Conway's Game of Life: Classic Mix, Glider Gun, Spaceships, Oscillators, Puffers, R-Pentomino, Acorn, Random Soup.
- HighLife (B36/S23): Replicator, Random Soup.
- Immigration Game: Color Mix, Random Soup.
- Rainbow Game: Rainbow Mix, Random Soup.
- Langton's Ant: Empty.
- Custom Rules: Random Soup starter pattern plus editable life-like B/S rules via Settings.
LifeGrid/
├── src/
│ ├── automata/ # Automaton implementations
│ ├── gui/ # GUI modules (app, config, state, ui, rendering)
│ └── main.py # Thin entry point (delegates to gui.app)
├── docs/ # README-style documentation
├── examples/ # Sample patterns
├── tests/ # Unit tests
├── requirements.txt
├── run.sh
├── LICENSE
└── README.md
Key GUI modules:
gui/app.py: High-level application orchestration.gui/ui.py: Widget construction and event wiring.gui/state.py: Mutable simulation state container.gui/config.py: Shared constants and mode registries.gui/rendering.py: Canvas drawing helpers.
- Launch tests with
pytest. Current coverage targets the Conway automaton; extending coverage for other modes is encouraged. flake8enforces an 80-character line limit; runflake8 src testsbefore committing.- To add a new automaton, implement it under
src/automata/, expose it fromautomata/__init__.py, and register it ingui/config.py. - The GUI is intentionally modular: prefer adding features in dedicated helper
modules rather than growing
gui/app.py.
Further details can be found in:
docs/USER_GUIDE.md– end-user walkthrough.docs/DEVELOPMENT.md– contributor guidelines and code map.
This project is distributed under the MIT License. See the LICENSE file for
full terms.