Small rules. Big consequences.
Conway's Rule Engine is a flexible and extensible framework for simulating Conway's Game of Life and other rule-based cellular automata. Built with Python and Pygame, it provides a visual simulation environment with highly customizable rules, initial patterns, and dynamic spawning behaviors.
- Configurable Conway's Game of Life simulation with customizable survival and birth rules
- Pygame-based visualization with real-time rendering
- Flexible initial pattern generation from any edge (top, bottom, left, right)
- Continuous cell spawning for dynamic, flowing animations
- JSON-based configuration for easy rule and parameter modification
- Modular architecture for easy extension and customization
All simulation parameters are configured via rules_config.json:
survival_min_rule: Minimum neighbors for a live cell to survive (default: 2)survival_max_rule: Maximum neighbors for a live cell to survive (default: 3)birth_rule: Number of neighbors needed for a dead cell to become alive (default: 3)
height_rule: Grid height in cellswidth_rule: Grid width in cellstick_rule: Updates per second (higher = faster simulation)
initial_spawn_direction: Where to spawn initial cells ("top", "bottom", "left", "right")initial_spawn_rows: Number of rows/columns to fill with initial patterninitial_alive_percentage: Probability (0.0-1.0) that each cell in the spawn area starts alive
continuous_spawn_rate: Probability (0.0-1.0) that new cells spawn each updatecontinuous_spawn_direction: Edge to continuously spawn from ("top", "bottom", "left", "right", "none")
conways_game/: Core Conway's Game of Life implementationcell_manager.py: Cell state logic and neighbor countingenv_manager.py: Grid management and update logicconways_game_of_life.py: Main game loop and rendering coordinationpygame_module/: Pygame visualization components
utils/: Utility modules (JSON reader, timing)rules_config.json: Configuration file for all simulation parametersmain.py: Entry point for running the simulation
- Clone the repository
- Install Python 3.x
- Install dependencies:
pip install pygame
- Configure your simulation in
rules_config.json - Run the simulation:
python main.py
{
"survival_min_rule": 2,
"survival_max_rule": 3,
"birth_rule": 3,
"continuous_spawn_rate": 0.0,
"continuous_spawn_direction": "none"
}{
"survival_min_rule": 2,
"survival_max_rule": 3,
"birth_rule": 3,
"continuous_spawn_rate": 0.3,
"continuous_spawn_direction": "bottom",
"initial_spawn_direction": "bottom",
"initial_spawn_rows": 10
}- Close the window to exit the simulation
The modular architecture allows for:
- Custom rule engines beyond Conway's Game of Life
- User-defined cellular automata rules
- Interactive cell placement and editing
- Pattern saving and loading