A JavaFX implementation of Conway's Game of Life — a zero-player cellular automaton where complex patterns emerge from four simple rules.
Each cell on the grid is either alive or dead. Every generation, the following rules are applied simultaneously to every cell:
- Underpopulation — A live cell with fewer than 2 neighbors dies
- Survival — A live cell with 2 or 3 neighbors lives on
- Overpopulation — A live cell with more than 3 neighbors dies
- Reproduction — A dead cell with exactly 3 neighbors becomes alive
- 160x90 grid (14,400 cells) with interactive click/drag to toggle cells
- Randomize to seed the grid with a random initial state
- Adjustable speed from 0.01s to 6s per generation
- Generation limiter to cap how many generations run
- Live birth/death counters in the toolbar
- Automatic dead-end detection — the simulation stops and shows a stats popup when it detects:
- Extinction — all cells have died
- Still life — the grid has stabilized with no changes
- Oscillators — a repeating cycle is detected (e.g. blinkers)
- End-of-simulation stats including generations survived, initial/final/peak population, total births and deaths, survival rate, and averages per generation
- Java 17+
- JavaFX SDK 21+ (not bundled with modern JDKs — download from Gluon)
# Set paths
export JAVA_HOME=/path/to/your/jdk
export FX=/path/to/javafx-sdk/lib
# Compile
$JAVA_HOME/bin/javac --module-path "$FX" --add-modules javafx.controls -d out src/game/*.java
# Copy resources
cp src/icon.png out/
# Run
$JAVA_HOME/bin/java --module-path "$FX" --add-modules javafx.controls --enable-native-access=javafx.graphics -cp out game.Game| Control | Action |
|---|---|
| Click / Drag | Toggle cells on/off |
| Randomize | Fill grid with random live cells |
| Start | Begin the simulation |
| Stop | Pause the simulation |
| Reset | Clear the grid and all counters |
| Speed spinner | Set seconds per generation |
| Generations spinner | Limit generations (0 = infinite) |
src/
game/
Game.java — JavaFX application, UI, and simulation loop
Platform.java — Grid logic, rules, cycle detection, and stats
Cell.java — Individual cell (extends Rectangle)
icon.png — Window icon
