The Game of Life
The first time I heard about the Game of Life was through Daniel Shiffman’s YouTube channel. I really didn’t get what it was, nor did I really give in the time to actually see what it was. It remained dormant in my mind for a while. That period of dormancy ended when YouTube recommended yet another video related to the Game of Life. This is when I really began taking the Game of Life seriously.
What’s the Game of Life?
Well, the Game of Life is what some would call a cellular automaton. A cellular automaton is usually, in theory, an infinite, two-dimensional grid composed of cells. Each cell has what’s called a state. A state could be anything anything, and in the case of the Game of Life, it’s either alive or dead. In the Game of Life, the state of each cell is governed by specific rules relating to the amount of alive or dead neighbors (in the case of the Game of Life, the neighbors are the cells: up, down, left, right, top right, top left, bottom right, and bottom left). Alright, I think a diagram would be helpful.
A thing to keep in mind: Each cell’s state gets updated after each discrete unit of time, and after that we’ve reached a new generation of cells. The initial configuration (or generation 0), is assigned by us. This will be relevant later.
The nice thing about the Game of Life, and cellular automata in general, is the fact that complexity arises from simple rules, and what’s even better is that we could use that to write a program in order to show us what would happen under specific rules. To begin, let’s review the rules of the Game of Life:
- If a cell is alive, and has less than 2 living neighbors, then it dies.
- If a cell is alive, and has 3 or 2 living neighbors, then it survives.
- If a cell is alive, and has more than 3 neighbors, then it dies.
- If a cell is dead, and has 3 neighbors, then it becomes alive.
Notice how these rules resemble how we, and other organisms, live. For example, if there are too many humans in an area, then they’ll probably die from overpopulation; and if there are only a few humans, then they’ll probably not manage to reproduce that much, and die from under population. However, if there are just the right amount of humans in an area and the right amount of resources were available, then they’ll survive. The name “Game of Life” doesn’t sound dramatic or out of reach anymore.
Recreating the Game of Life?
I’ll try to recreate the Game of Life in Processing.py, a Python framework. If you’ve watched some of the Daniel Shiffman’s videos, you’ll probably have an idea of what it is. If not, then the only thing you’re going to have to know is that this specific framework allows for its user to process images and draw shapes. My attempt to implement the Game of Life is something I’m going to share in the next article.