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:
- Any live cell with two or three live neighbors survives.
- Any dead cell with three live neighbors becomes a live cell.
- 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
Top comments (22)
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.
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
Source: github.com/franky47/genetic-life/b...
The greatest solution I've ever seen is written in APL.
If you're anything like me you'll try and implement the same reasoning in a different language.
I am utterly fascinated by APL/J/family. Just need more hours in the week...
twitter.com/wilson_tovar_/status/1...
Made in Crystal <3
I just started learning Crystal this week! Definitely taking a look, thanks for sharing.
Crystal is amazing. I'm love with that language <3
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:
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.
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.
Sad news. One of many upcoming, I'm afraid.
Here is a playlist with John Conway interviews made by Numberphile channel
youtube.com/playlist?list=PLt5AfwL...
Just recently finished one. Check this out!
demo: krikchaip.github.io/game-of-life
source: github.com/krikchaip/game-of-life
This is a nice, clean implementation! Thanks for sharing.
I wrote Game of Life in JS. Check out the link, you can even play with it
dinesh-gdk.github.io/Game-Of-Life/
Great implementation, thank you for sharing!
Some comments may only be visible to logged-in visitors. Sign in to view all comments. Some comments have been hidden by the post's author - find out more