Game of Life Design Patterns Study
A Python and Pygame study that applies design patterns, SOLID principles, and clearer architectural boundaries to Conway's Game of Life.
Technologies
- Python
- Pygame
- NumPy
- pytest
- Docker
Overview
The goal was not only to make the game work, but to study how a small Pygame application could be organized with clearer responsibilities. The original implementation remains available as a reference while the refactored application is organized under a dedicated package.
Patterns implemented
The refactoring uses four patterns to make responsibilities and dependencies explicit.
- Strategy: switches between Conway and HighLife evolution rules without changing the game engine.
- State: models Editing, Running, and Paused simulation modes without spreading conditional logic through the application.
- Publisher/Subscriber: lets simulation events notify summary and logging subscribers through an interface.
- Factory: centralizes state object creation without coupling concrete states directly to one another.
Architecture and lessons learned
The architecture keeps Pygame input and rendering in the UI layer, while the engine, grid, strategies, and subscribers remain independent from the UI. This supports SOLID-oriented boundaries and makes the system easier to reason about.
This is a study repository, not a definitive implementation. The pattern-focused choices are intentionally visible so their trade-offs can be examined; the same application could use different patterns or a simpler design.