Skip to content

Latest commit

 

History

History
39 lines (28 loc) · 3.15 KB

README.md

File metadata and controls

39 lines (28 loc) · 3.15 KB

Implementation of John Conway's Game of Life in Java with Javax Swing GUI

  1. Description
  2. Features
  3. Installation

Description

This is a simple implementation of John Conway's Game of Life in Java with a GUI made with Javax Swing. The Game of Life is a cellular automaton devised by the British mathematician John Horton Conway in 1970. Conway once called it a zero-player game, as its evolution is determined by its initial state, requiring no further input. One interacts with the Game of Life by creating an initial configuration and observing how it evolves.

The rules of the Game of Life are simple.: The game is played on an infinite two-dimensional grid of square cells, each of which is in one of two possible states, live or dead. Every cell interacts with its eight neighbours, which are the cells that are horizontally, vertically, or diagonally adjacent. At each step in time, the following transitions occur:

  • Any live cell with fewer than two live neighbours dies, as if by underpopulation.
  • Any live cell with two or three live neighbours lives on to the next generation.
  • Any live cell with more than three live neighbours dies, as if by overpopulation.
  • Any dead cell with exactly three live neighbours becomes a live cell, as if by reproduction.

As the Game of Life is turing complete (see also here and compare to another turing complete cellular automaton Rule 110), it can simulate any algorithm or computation that can be performed by a computer. Especially interesting are the so called Spaceships which are patterns that move across the board. The Gosper Glider Gun is a pattern that creates infinitely many Gliders (small spaceships) in a loop.

Other common patterns are Oscillators like the Toad or the Pulsar, which are pattern that oscillates between two or more states, and Still Lifes, which are static patterns like the Block or the Boat that remain the same in every generation.

Features

The user can:

  • start and stop the game.
  • clear the board.
  • change the speed of the game.
  • change the size of the cells.
  • change the size of the board by resizing the window.
  • interact with the game while it is running, by holding the mouse button and dragging the cursor over the cells to make them alive or dead.
  • import famous patterns from the menu. (e.g. Glider, Gosper Glider Gun, etc.)

Installation

  1. Clone the repository with git clone [email protected]:sirrenberg/Game-of-Life.git
  2. Change to the directory with cd Game-of-Life/src/
  3. Compile the program with javac gol/GameOfLifeMain.java
  4. Execute the program with java gol.GameOfLifeMain