If you spend a lot of time working with the Linux terminal, you may already have delusions of divine power—especially if you're logged in as root.

Take some time out from raining frogs on your users with this classic cellular automata simulation, and sit back as evolution takes its course.

What Is Conway's Game of Life?

woman using a microscope

Conway's Game of Life isn't a game in the classic sense, as you don't interact with it. Instead, you create an initial configuration of cells and watch as they interact and evolve according to a strict set of rules.

Evolution takes place across an infinite grid of cells, so there's theoretically no limit to how far your creation can spread, and as the game is Turing complete, there's also no limit on what it can create.

The famous infinite monkey theorem, states that a monkey hitting random typewriter keys will, given infinite time, type every conceivable text.

It's inevitable that given the same conditions, the game will eventually and momentarily arrange the cells into the complete works of Shakespeare, narrate your innermost secrets, tell you when your tech will stop receiving support, and reveal the meaning of the answer to the ultimate question of life, the universe, and everything.

It's also a fun way to pass an idle half hour in the terminal while you're downloading ISOs or running automated tests.

How to Install Conway's Game of Life on Linux

clone and compile conway

The game is written in Haskell, and you need to have Haskell's stack installed on your system to compile it.

The easiest way to install the stack on Debian or Ubuntu is to open a terminal and enter:

        sudo apt install haskell-stack
    

Alternatively, and for other distros, you can download and execute an installation script:

        curl -sSL https://get.haskellstack.org/ | sh
    

The script will ask for your sudo password to install dependencies and to place binaries into /usr/local/bin.

The app also needs the libtinfo-dev package to compile:

        sudo apt install libtinfo-dev
    

To install the Game of Life, clone its GitHub repository and use the cd command to move into it:

        git clone https://github.com/samtay/conway.git && cd conway
    

Compile the program with:

        stack build
    

Finally, install it with:

        stack install life
    

Be a Command-Line Deity With Conway's Game of Life!

conway game of life in progress

As the Game of Life is a simulation rather than a true game, the starting conditions are critical to how it develops.

Fire up the TUI by entering:

        life
    

The bulk of the window will be taken up with a blank frame containing a blue cursor. You can move this around the screen using the arrow keys on your keyboard. Press Enter to add or remove a cell.

The rules are simple:

  • If a live cell is flanked by fewer than two neighbors, it will die and disappear
  • If a dead cell has three live neighbors, it becomes a live cell
  • If a live cell has three live neighbors, it dies
  • If a live cell has either two or three live neighbors, it survives to the next iteration
conway game starting state

If you're short on inspiration, you can select from a pre-made range of shapes by pressing the # key, followed by numbers 0 to 9.

You will also be able to add or delete individual cells during the simulation by pressing the Enter key, like a spiritual being indulging in a little immaculate conception or smiting.

When you're ready to start the simulation, hit Space. You can also use this key to pause. The play area is theoretically infinite, and you can pan around it using the arrow keys.

As your lunch break draws to a close, and you're anxious to see how the simulation plays out, you can press Ctrl + > to speed it up. If you want to take some more time to examine the evolution in action, press Ctrl + <.

Be a God on the Terminal Chessboard, Too!

There's no shortage of games you can play in the Linux terminal. If you want to take a more active role in the lives of your virtual subjects, consider playing a game of chess over SSH.