Conway's Game Of Life




Tools

Conway's Game of Life is a zero-player game, meaning that 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 universe of the Game of Life is an infinite two-dimensional orthogonal grid of square cells, each of which is in one of two possible states, alive 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:

  1. Any live cell with fewer than two live neighbours dies, as if caused by under-population.
  2. Any live cell with two or three live neighbours lives on to the next generation.
  3. Any live cell with more than three live neighbours dies, as if by over-population.
  4. Any dead cell with exactly three live neighbours becomes a live cell, as if by reproduction.

INSTALLATION

We can install the source files to our ~/Desktop/ by cloning the following Git repository 

$ cd ~/Desktop/

$ git clone https://github.com/ara-martirossyan/Game-of-life.git

Now we have the ~/Desktop/Game-of-life directory with the source .java files situated in ~/Desktop/Game-of-life/src/ directory

Game-of-life
├── bin
│   └── manifest.txt
├── logo.jpg
├── README.md
└── src
    ├── ConwaysLife.java
    └── MyPanel.java

Let's compile the src files into the bin directory

$ cd ~/Desktop/Game-of-life/src/

$ javac -d ../bin *.java

and we end up having

Game-of-life
├── bin
│   ├── ConwaysLife.class
│   ├── manifest.txt
│   └── MyPanel.class
├── logo.jpg
├── README.md
└── src
    ├── ConwaysLife.java
    └── MyPanel.java

Now let's make the .jar file  inside ~/Desktop/Game-of-life/

$ cd ~/Desktop/Game-of-life/bin

$ jar -cvmf manifest.txt ../game-of-life.jar *.class

 we get

Game-of-life
├── bin
│   ├── ConwaysLife.class
│   ├── manifest.txt
│   └── MyPanel.class
├── game-of-life.jar
├── logo.jpg
├── README.md
└── src
    ├── ConwaysLife.java
    └── MyPanel.java

Let's go to ~/Desktop/Game-of-life/

$ cd ~/Desktop/Game-of-life/

and from there run the following command to play the game

$ java -jar game-of-life.jar

Voila! Now press on "GUN" button and then "PLAY" button to play!