Life is played on a grid of square cells--like a chess board but extending infinitely (in theory) in every direction. A cell can be alive or dead. A live cell is shown by a colored square. A dead cell is shown by leaving the square empty (i.e white). Each cell in the grid has a neighborhood consisting of the eight cells in every direction including diagonals.
This screenshot shows a cell (red) and its eight neighbors (blue)
To apply each step of the rules, we count the number of live neighbors for each cell. What happens next depends on this number. Here are the rules:
A dead cell (red) with exactly three live neighbors (blue) becomes a live cell (birth).
A live cell with two or three live neighbors stays alive (survival).
In all other cases, a cell dies or remains dead (overcrowding if more than 3 neighbors or loneliness if less than 2 neighbors).
The number of live neighbors is always based on the cells before the rule was applied. In other words, you must first find all of the cells that change before changing any of them.