Skip to content

davmoz/Game-Of-Life

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Game of Life

A JavaFX implementation of Conway's Game of Life — a zero-player cellular automaton where complex patterns emerge from four simple rules.

A snapshot of the game

Rules

Each cell on the grid is either alive or dead. Every generation, the following rules are applied simultaneously to every cell:

  1. Underpopulation — A live cell with fewer than 2 neighbors dies
  2. Survival — A live cell with 2 or 3 neighbors lives on
  3. Overpopulation — A live cell with more than 3 neighbors dies
  4. Reproduction — A dead cell with exactly 3 neighbors becomes alive

Features

  • 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

Requirements

  • Java 17+
  • JavaFX SDK 21+ (not bundled with modern JDKs — download from Gluon)

Building and Running

# 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

Controls

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)

Project Structure

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

About

Lacking a decent cell-randomizing algorithm, but playable in general.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages