## DEV Community is a community of 641,972 amazing developers

We're a place where coders share, stay up-to-date and grow their careers.

# Share Your Conway's Game Of Life

Ben Lovy
Just this guy, you know?

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

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.

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:

genetic-life.surge.sh

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.

Ben Lovy

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

Ben Lovy

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

Wilson Tovar

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

Roger Zanoni

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

gist.github.com/rogerzanoni/6381027

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:

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.

Ben Lovy

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

Gerard Klijs

I made 2d and 3d versions learning rust with web assembly. Online at gameoflife2d.gklijs.tech/ and gameoflife3d.gklijs.tech/. Code at github.com/gklijs/game-of-life.

Kostia Palchyk

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

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