A Java implementation of Conway's famous cellular automaton - the Game of Life. This zero-player game demonstrates how complex patterns can emerge from simple rules, creating an engaging simulation of artificial life.
Conway's Game of Life is a cellular automaton devised by mathematician John Horton Conway in 1970. It consists of a grid of cells that can be either alive or dead, with each cell's fate determined by its neighbors according to simple rules. Despite its simplicity, the Game of Life is Turing complete and can simulate complex behaviors.
The universe evolves according to four fundamental rules:
- Underpopulation: Any live cell with fewer than two live neighbors dies
- Survival: Any live cell with two or three live neighbors survives
- Overpopulation: Any live cell with more than three live neighbors dies
- Reproduction: Any dead cell with exactly three live neighbors becomes alive
- Interactive GUI: User-friendly graphical interface for game visualization
- Real-time Simulation: Watch patterns evolve step by step
- Pattern Library: Pre-loaded famous patterns (gliders, oscillators, still lifes)
- Custom Grid Setup: Create your own initial configurations
- Speed Control: Adjust simulation speed to observe different behaviors
- Grid Customization: Configurable grid size and cell appearance
- Pattern Analysis: Track population statistics and generation count
- Java 8 or higher
- Any Java IDE (IntelliJ IDEA, Eclipse, NetBeans) or command line
- Clone the repository:
git clone https://github.com/voloshynm/com.voloshyn.gameoflife.git
cd com.voloshyn.gameoflife
- Compile the project:
javac -d bin src/com/voloshyn/gameoflife/*.java
- Run the application:
java -cp bin com.voloshyn.gameoflife.Main
- Open the project in your preferred Java IDE
- Ensure the source folder is set to
src/ - Run the main class:
com.voloshyn.gameoflife.Main
| Action | Description |
|---|---|
| Click Cell | Toggle cell state (alive/dead) |
| Start/Pause | Begin or pause the simulation |
| Step | Advance one generation manually |
| Clear | Reset all cells to dead state |
| Random | Generate random initial pattern |
- Manual Setup: Click individual cells to create your pattern
- Load Presets: Choose from classic patterns like:
- Glider: Moving pattern that travels across the grid
- Blinker: Simple oscillator that alternates between two states
- Block: Static pattern that never changes
- Gosper Glider Gun: Generates an infinite stream of gliders
- Speed Slider: Control how fast generations advance
- Generation Counter: Track the current generation number
- Population Display: Monitor live cell count over time
- Grid Size: Adjust the playing field dimensions
com.voloshyn.gameoflife/
├── src/
│ └── com/voloshyn/gameoflife/
│ ├── Main.java # Application entry point
│ ├── GameOfLife.java # Core game logic and rules
│ ├── GameBoard.java # Grid representation and cell management
│ ├── GameGUI.java # User interface components
│ ├── Cell.java # Individual cell state and behavior
│ ├── Pattern.java # Predefined pattern definitions
│ └── Utils.java # Utility functions and helpers
├── .idea/ # IntelliJ IDEA configuration
├── com.voloshyn.gameoflife.iml # IntelliJ module file
└── README.md
Game Engine: Implements Conway's rules with efficient neighbor counting algorithms
Grid Management: Dynamic 2D array handling with boundary conditions
Pattern Recognition: Identifies and categorizes common Life patterns
Performance Optimization: Optimized algorithms for large grid simulations
GameOfLife: Central game engine managing state transitions
GameBoard: Grid data structure with cell state management
GameGUI: Swing-based user interface with interactive controls
Cell: Represents individual cell with state and neighbor information
Pattern: Library of famous Game of Life configurations
- Block: 2×2 square of live cells
- Beehive: Hexagonal arrangement of 6 cells
- Loaf: Asymmetric 7-cell pattern
- Blinker: 3-cell horizontal/vertical alternator
- Toad: 6-cell period-2 oscillator
- Beacon: 6-cell period-2 oscillator
- Glider: 5-cell diagonal traveler
- Lightweight Spaceship: Faster horizontal traveler
- Gosper Glider Gun: Produces infinite stream of gliders
- Acorn: Small pattern that grows for 5,206 generations
Try these fascinating configurations:
- Population Dynamics: Start with random 50% density and observe stabilization
- Pattern Collisions: Launch gliders at each other to see interaction results
- Garden of Eden: Create patterns that cannot arise naturally
- Methuselahs: Small patterns that take many generations to stabilize
Contributions are welcome! Here are some ways to help:
- Add more predefined patterns
- Implement pattern import/export functionality
- Create pattern recognition algorithms
- Add sound effects and animations
- Implement toroidal (wraparound) grid option
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
- Conway's Game of Life - Wikipedia
- LifeWiki - Pattern Database
- Mathematical Properties of Life
- Cellular Automata Theory
This project is open source and available under the MIT License.
Maksym Voloshyn
- GitHub: @voloshynm
- Email: maksym.voloshyn.002@student.uni.lu
- John Horton Conway - Creator of the Game of Life
- Martin Gardner - Popularized the game in Scientific American
- The Life Community - Decades of pattern discovery and analysis
- Java Swing Framework - GUI development platform
"The Game of Life is not just a game, but a fascinating glimpse into how complexity can emerge from simplicity."
Keywords: java cellular-automaton game-of-life conway simulation swing-gui mathematical-recreation artificial-life