Simulation game with Pygame
As a last example, we will simulate life with Conway's Game of Life. The original game of life is based on a few basic rules. We start out with a random configuration on a two-dimensional square grid. Each cell in the grid can be either dead or alive. This state depends on the neighbors of the cell. You can read more about the rules at http://en.wikipedia.org/wiki/Conway%27s_Game_of_Life#Rules At each step in time, the following transitions occur:
- Live cells with less than two live neighbors die.
- Live cells with two or three live neighbors live on to the next generation.
- Live cells with more than three live neighbors die.
- Dead cells with exactly three live neighbors become a live cell.
Convolution can be used to evaluate the basic rules of the game. We need the SciPy package for the convolution process.