This repo contains my own JavaScript implementation of an interactive and dynamic version of Conway's Game of Life—dynamic because the rules can be changed on the fly (and the results visualized in real time), and interactive because the user can change them. The user can also interact directly with the Game by clicking cells in the grid to toggle them on and off. If you're not familiar with Conway's Game of Life, read the Background section below or check out its Wikipedia entry.
In this implementation, the survival values (the number(s) of neighbors necessary for a cell to survive to the next generation) take on a range rather than discrete values. In other words, there's an Smin and an Smax, and if a cell has N neighbors, then it will survive to the next generation if Smin ≤ N ≤ Smax. The birth value is a single value rather than a range.
As an example, the birth value and survival range in the screenshot below would be expressed in the usual Game of Life notation as B1/S456.
This implementation, which is essentially a simplified, dynamic version of the Larger than Life ruleset that allows the rules to be changed in real time in the midst of a Game, can make for some interesting behavior.
The grid is fixed to be square, but its size (number of rows/columns) can be adjusted. The grid can be randomized, and the random seed density (probability that a given cell will be alive) can also be adjusted.
Conway's Game of Life is a cellular automaton, i.e., a "game" consisting of a 2D grid in which each cell (square) of the grid can be either "alive" (on) or "dead" (off). The 8 cells surrounding any given cell are called its neighbors.
The original rules are as follows:
-
Any living cell with exactly 2 or 3 neighbors survives to the next generation—otherwise, it dies.
-
Any dead cell with exactly 3 neighbors becomes alive during the next generation, i.e., it is "born."
This is notated B3/S23, where the B indicates the number(s) of neighboring cells necessary for a new cell to be born from a dead cell and S denotes the number(s) of neighboring cells necessary for a living cell to survive to the next generation.