DEV Community

Cover image for Share Your Conway's Game Of Life

Share Your Conway's Game Of Life

Ben Lovy
Just this guy, you know?
・2 min read

Sadly, John Horton Conway has passed away. While Conway's contributions to computational mathematics over the years are numerous and eclectic, many aspiring coders are introduced to his work via Conway's Game of Life, a cellular automaton that's relatively simple to implement.

In the Game of Life, you provide an initial state, or seed, to a square grid of cells. Each cell is either "on" or "off", and the next state of the grid is calculated via these rules, as stated on Wikipedia:

  1. Any live cell with two or three live neighbors survives.
  2. Any dead cell with three live neighbors becomes a live cell.
  3. All other live cells die in the next generation. Similarly, all other dead cells stay dead.

As this is relatively simple to write logic for, many programmers take a stab at implementing such a program early in their careers. Here's mine on GitHub, from July 2017, as one of my first Rust programs - but not terribly interesting to look it as it just renders world states in text to the terminal. However, it does demonstrate how trivial the core logic is to write:

//tick_cell takes a Coord and a World and returns the next state of the cell
fn tick_cell(c: &Coord, w: &World) -> bool {
    let s = moore_sum(c, w);
    if get_cell(c, w) {
        match s {
            2 | 3 => true, //ALIVE
            _ => false, //overcrowded or starved
    } else {
        match s {
            3 => true, //3 gives birth
            _ => false, //barren

Do you have a Game of Life to show us? Bonus points for an implementation we can play with - my entry must be downloaded and compiled, but I'm sure some of you web-dev-y types have something more interactive!

What are some of your favorite seeds? Are there other cellular automata that interest you?

Alternatively, what other John Conway work has inspired you? According to this redditor, Conway was frustrated that the Game of Life was his most well-known contribution. What else do you remember him for?

Image: wikimedia commons

Discussion (20)

bch77 profile image

I have an implementation that I made on Shadertoy It is very playable-with in a desktop browser (read the code for extensive usage notes). It's somewhat limited in field size, however.

I am so sad and angry that COVID-19 took JHC. I remember him for various things beyond Life, including his analysis of the Rubik's cube, Sprouts, and his work with uniform polychora. He was such a shining light and will be hugely missed.

franky47 profile image
François Best • Edited

Here's mine, with a genetic twist: cells have color genes, that are passed from their three parents. It creates a colorful battle of color factions over time, I built it while learning Rust:


gypsydave5 profile image
David Wickes • Edited

The greatest solution I've ever seen is written in APL.

    ↑1 ⍵∨.∧3 4=+/,¯1 0 1∘.⊖¯1 0 1∘.⌽⊂⍵ 

If you're anything like me you'll try and implement the same reasoning in a different language.

deciduously profile image
Ben Lovy Author

I am utterly fascinated by APL/J/family. Just need more hours in the week...

wilsontov profile image
deciduously profile image
Ben Lovy Author

I just started learning Crystal this week! Definitely taking a look, thanks for sharing.

wilsontov profile image
Wilson Tovar

Crystal is amazing. I'm love with that language <3

rogerzanoni profile image
Roger Zanoni

Very old (7 years ago, every time I comment here I feel older :) and not very efficient:

It's written in QML and if we change the import to at least QtQuickt 2.0 and world width, height to 100, it looks like this:


karataev profile image
Eugene Karataev

Here's my Life game. And the repo.

I wrote it 5 years ago when just started my path in frontend development. AngularJS, ES5, script tags, no bundlers...

RIP professor Conway.

krikchaip profile image
deciduously profile image
Ben Lovy Author

This is a nice, clean implementation! Thanks for sharing.

gklijs profile image
Gerard Klijs

I made 2d and 3d versions learning rust with web assembly. Online at and Code at

kosich profile image
Kostia Palchyk

Sad news. One of many upcoming, I'm afraid.

Here is a playlist with John Conway interviews made by Numberphile channel

aka_dude profile image
Andrew Andersen

I wrote mine to try using OpenCL, so it uses GPU for simulation, but I didn't bother myself with proper rendering. Also, host language is Rust :)

Some comments have been hidden by the post's author - find out more

Forem Open with the Forem app