Conway’s Game of Life implemented in Java with two simulation strategies and two renderers (console and Jaylib/Raylib). Made to explore design choices and performance trade-offs when simulating cellular automata in Java.
The Game of Life is a zero-player cellular automaton. The universe is an infinite 2D orthogonal grid of square cells; each cell is either alive or dead. On each tick (generation) every cell transitions according to its 8 neighbors:
- A live cell with fewer than two live neighbours dies (underpopulation).
- A live cell with two or three live neighbours lives on.
- A live cell with more than three live neighbours dies (overpopulation).
- A dead cell with exactly three live neighbours becomes alive (reproduction).
More: https://en.wikipedia.org/wiki/Conway%27s_Game_of_Life
- Download the executable from the latest release.
- Run it using one of the following options:
java -jar game-of-life-1.0-release.jarjava -jar game-of-life-1.0-release.jar fastjava -jar game-of-life-1.0-release.jar consolejava -jar game-of-life-1.0-release.jar console 32java -jar game-of-life-1.0-release.jar fast consolejava -jar game-of-life-1.0-release.jar console 1024- Java Development Kit (JDK) 21 or higher
- Maven
- (Optional) VS Code + Java Extension Pack
git clone https://github.com/AdrielHercules/java-game-of-life.git
cd java-game-of-life
mvn clean install
mvn clean package
# Run after build
java -jar target/game-of-life-1.0-release.jarThis project includes microbenchmarks written with JMH to compare the performance of the two implementations.
mvn clean verify
java -cp .\target\game-of-life-1.0-release.jar org.openjdk.jmh.MainThe project provides two different approaches to simulating the game, allowing comparison of design and performance trade-offs:
gameoflife.simulation.oop— Object-oriented approach. Cells and board modeled as objects; prioritizes clarity and extensibility.gameoflife.simulation.fast— Data-driven / performance focused approach. Uses primitive arrays and cache-friendly algorithms to maximize speed and reduce GC overhead.
The project provides two ways of rendering the simulation:
ConsoleViewer— ASCII-based rendering in the terminalRaylibVisualizer(Raylib via Jaylib) - 2D renderer using Jaylib (A Java Raylib binding).
Feel free to submit issues, pull requests and new features.