John Conway's game of life
Introduction
I've always wanted to write an implementation of John Conway's game of life, but I never had a good graphical toolkit that I was excited about. I've always felt like HTML+SVG was a little bit of a cop-out, but since learning D3js, I'm an absolute convert.
I'll hack on this a bit and then explain it…
The Rules
The "universe" is a two dimensional grid of square cells. A cell has two states, alive or dead. The universe evolves from an initial configuration of alive cells. The rules for transitioning from one state to another are:
- If a cell is alive with less than two neighbors it dies.
- Live cells with two or three live neighbors lives.
- Live cells with more than three neighbors dies.
- A dead cell with exactly three live neighbors becomes live.